Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Ok, here's an easy one

by abitkin (Monk)
on Sep 08, 2002 at 19:53 UTC ( #196085=note: print w/ replies, xml ) Need Help??


in reply to Zero padding numbers (was: Ok, here's an easy one)

sprintf is too easy, here's a fun way.

#!/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.)


Comment on Re: Ok, here's an easy one
Download Code
Re: Re: Ok, here's an easy one
by I0 (Priest) on Sep 09, 2002 at 03:13 UTC
    $num = substr("00".$num,-2);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://196085]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2014-07-22 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (113 votes), past polls