in reply to (tye)Re: Zero Padding
in thread Zero Padding

This edges out substr() in my benchmarks:

my $padded = '0' x ($wid - length $num) . $num;

Replies are listed 'Best First'.
(tye)Re2: Zero Padding
by tye (Sage) on Feb 03, 2001 at 09:42 UTC

    And it doesn't have the perhaps significant disadvantage of my favorite substr method of truncating numbers that are too wide. ):

            - tye (but my friends call me "Tye")