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")