Perl: the Markov chain saw | |
PerlMonks |
Re: front-pad a number with zero'sby japhy (Canon) |
on Oct 30, 2001 at 23:27 UTC ( [id://122168]=note: print w/replies, xml ) | Need Help?? |
That's broken, due to the use of the string comparison operators (like lt) in the place of numerical comparison operators (like <). Also, a while loop can be replaced with math:
But honestly, this is a job for sprintf(): That is, sprintf("%05d", 123) returns 00123.
_____________________________________________________
In Section
Cool Uses for Perl
|
|