in reply to front-pad a number with zero's
But honestly, this is a job for sprintf():$string = ('0' x ($wanted - $current)) . $string;
That is, sprintf("%05d", 123) returns 00123.sprintf "%0${len}d", $number;
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: front-pad a number with zero's
by Anonymous Monk on Jun 13, 2008 at 08:40 UTC | |
by andreas1234567 (Vicar) on Jun 13, 2008 at 09:27 UTC | |
by Anonymous Monk on Aug 27, 2011 at 01:35 UTC |