You code has only two print statements, but your output shows three lines; it's a little unclear whether you've inadvertantly omitted another print statement.
However, presuming that the missing code looks like these two lines:
$v += $v; print "$v\n";
I may have an explanation.
Which is, the increment and decrement operators, in particular, can be used to increment strings. In other words, they are not strictly numeric operations.
my $x = 'A'; ++$x; print "$x\n";
would print
BSo, changing the ++ to += 1 in your example produces different results.
prints:use warnings; use strict; my $v = 99; $v = sprintf( "%04d", $v ); print "$v\n"; $v += 1; print "$v\n"; $v += $v; print "$v\n";
0099 100 200
dmm
You can give a man a fish and feed him for a day ...In reply to Re: Leading zero's, and their persistance
by dmmiller2k
in thread Leading zero's, and their persistance
by LogicalChaos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |