[ic] {Spam?} Re: Leading 0 - calc issue.
Rick Bragg
lists at gmnet.net
Tue Sep 6 19:43:08 UTC 2011
On Tue, 2011-09-06 at 15:27 -0400, Rick Bragg wrote:
> I am trying to increment a number and keep it's leading 0. (I need the
> result to be 2 digits long)
>
> The following works fine and returns "08":
>
> [tmp number]07[/tmp]
> [calc]
> my $num = [scratch number]+1;
> $num = sprintf("%2d", $num);
> $num =~ tr/ /0/;
> return $num;
> [/calc]
>
> However, if I use 08, or 09, I get "0" returned. Any idea why?
>
> [tmp number]08[/tmp]
> [calc]
> my $num = [scratch number]+1;
> $num = sprintf("%2d", $num);
> $num =~ tr/ /0/;
> return $num;
> [/calc]
>
> [tmp number]09[/tmp]
> [calc]
> my $num = [scratch number]+1;
> $num = sprintf("%2d", $num);
> $num =~ tr/ /0/;
> return $num;
> [/calc]
>
> Thanks!
> Rick
>
Using $Scratch->{number} fixes it but I'm just wondering why [scratch
number] does not work?
Rick
More information about the interchange-users
mailing list