in reply to help needed in printing the numbers

perldoc -q pad points out the sprintf function:

my $padded = sprintf "%03s", $number;