in reply to Number Padding

Why won't sprintf function for your purposes?

#!/usr/bin/perl foreach $p ( 2..5 ) { print sprintf ("%0${p}d\n", $p); } __END__ prints: 02 003 0004 00005

Replies are listed 'Best First'.
Re^2: Number Padding
by ihb (Deacon) on May 27, 2005 at 18:27 UTC

    Don't forget the star syntax:

    sprintf '%0*d', $len, $value;

    ihb

    See perltoc if you don't know which perldoc to read!