in reply to Formating Numbers Preceding 0's

This is one way to accomplish the task:

#!/usr/bin/perl -w # # my @data = (7, 314, 23, 513465, 4444, 29 ); for (@data) { print " Num: ", six_zeroes($_), "\n"; } sub six_zeroes { my $num = shift; return substr("000000" . $num, -6 ); }
And the results are:

~/perl/perlmonks$ ./leading_zeroes.pl Num: 000007 Num: 000314 Num: 000023 Num: 513465 Num: 004444 Num: 000029