Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

photo finish

by petral (Curate)
on Oct 31, 2001 at 21:07 UTC ( [id://122375]=poem: print w/replies, xml ) Need Help??

On Oct 30, 2001 at 13:22 a brother posted a 10 line snippet to put leading 0's on numbers. The first 3 responses were:
 Re: front-pad a number with zero's
 by japhy on Oct 30, 2001 at 13:27

      . . .

      But honestly, this is a job for sprintf():


      sprintf "%0${len}d", $number;

      That is, sprintf("%05d", 123) returns 00123.



 Re: front-pad a number with zero's
 by Masem on Oct 30, 2001 at 13:27


       Why not (simply)?:


       $string = sprintf( "%05d", $number );



 Re: front-pad a number with zero's
 by lhoward on Oct 30, 2001 at 13:27


       You can do the same thing with sprintf.


       my $f=sprintf("%05d",123);

       will put "00123" into $f.


Replies are listed 'Best First'.
(tye)Re: photo finish
by tye (Sage) on Oct 31, 2001 at 22:06 UTC

    Further research shows:

    2001-10-30 18:27:37- japhy's note
    2001-10-30 18:27:42- masem's note
    2001-10-30 18:27:45- lhoward's note
    (for the morbidly curious, like me). An 8-second spread is pretty impressive. (:

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: poem [id://122375]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-18 03:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found