in reply to Zero padding numbers (was: Ok, here's an easy one)
sprintf is too easy, here's a fun way.
I only mention it, becuase sometimes you want to pad with something other than 0's (for example "." when doing a TOC listing.)
#!/usr/bin/perl my $num = 5; $num = substr("00",2-length($num)) . $num if length($num)<2; print $num;
I only mention it, becuase sometimes you want to pad with something other than 0's (for example "." when doing a TOC listing.)
In Section
Seekers of Perl Wisdom