LogicalChaos has asked for the wisdom of the Perl Monks concerning the following question:
The output is:use warnings; use strict; my $v = 99; $v = sprintf( "%04d", $v ); print "$v\n"; ++$v; print "$v\n";
Adding 1 to 99 and getting 100 shows that we're not incrementing in string land, so why does one numerical method preserve the leading 0 and not the other?0099 0100 200
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Leading zero's, and their persistance
by derby (Abbot) on Jan 08, 2002 at 01:59 UTC | |
|
Re: Leading zero's, and their persistance
by dmmiller2k (Chaplain) on Jan 08, 2002 at 01:48 UTC | |
|
Re: Leading zero's, and their persistance
by danger (Priest) on Jan 08, 2002 at 01:55 UTC | |
|
Re: Leading zero's, and their persistance
by LogicalChaos (Beadle) on Jan 08, 2002 at 02:54 UTC |