That's broken, due to the use of the string comparison operators (like lt) in the place of numerical comparison operators (like <). Also, a while loop can be replaced with math:
$string = ('0' x ($wanted - $current)) . $string;
But honestly, this is a job for sprintf():
sprintf "%0${len}d", $number;
That is, sprintf("%05d", 123) returns 00123.
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??; |