"be consistent" | |
PerlMonks |
Re: sprintf() returning incorrect valueby flexvault (Monsignor) |
on Jul 15, 2015 at 18:10 UTC ( [id://1134941]=note: print w/replies, xml ) | Need Help?? |
Welcome ppeel, This may be my experience only, but I've had problems keeping leading zeros ('0'), in a variable ( especially hashes and arrays ) within a long running script. So instead of using 'sprintf', I usually add a number with the correct number of zeros, and then use 'substr' to remove it when I need to print, etc. So your: becomes for me: Then when I need to print/etc. the result, I do: I have only experienced this when I add the zeros and then use the variables much later. YMMV. (Note: It also could have been a bug in the version of Perl that I was using which is now fixed. :-) Regards...Ed "Well done is better than well said." - Benjamin Franklin
In Section
Seekers of Perl Wisdom
|
|