in reply to Adding Leading Zeros

Simple trick with perl. use strings instead of numbers:

    foreach my $index ('00'..'12') {
vs
    foreach my $index (00..12) {

Replies are listed 'Best First'.
Re^2: Adding Leading Zeros
by Anonymous Monk on Aug 29, 2016 at 18:28 UTC

    Oh! You must mean some like this:

    my @inputs = (20188, 18350, 4005, 127736, 10291, 4937, 57500, 150494); sub with_zeroes { grep( $_ == $_[0], '0000000000' .. '9999999999' ) } say with_zeroes($_) for @inputs;
    Small doubt about efficiency remains however.