Ahh but you are incrementing in string land (and integer land is left alone). I missed what operation you used to get to 200 but it probably forced a switch from the PV value to the IV (or maybe NV). Use Devel::Peek to check:
use warnings; use strict; use Devel::Peek; my $v = 99; print Dump( $v ); $v = sprintf( "%04d", $v ); print "$v\n"; print Dump( $v ); ++$v; print "$v\n"; print Dump( $v ); ++$v; print "$v\n"; print Dump( $v );
and the output:
SV = IV(0x8101d8c) at 0x8118330 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK,IsUV) UV = 99 0099 SV = PVIV(0x80f6ba8) at 0x8118330 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) IV = 99 PV = 0x8103178 "0099"\0 CUR = 4 LEN = 5 0100 SV = PVIV(0x80f6ba8) at 0x8118330 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) IV = 99 PV = 0x8103178 "0100"\0 CUR = 4 LEN = 5 0101 SV = PVIV(0x80f6ba8) at 0x8118330 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) IV = 99 PV = 0x8103178 "0101"\0 CUR = 4 LEN = 5
-derby
In reply to Re: Leading zero's, and their persistance
by derby
in thread Leading zero's, and their persistance
by LogicalChaos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |