jimt has asked for the wisdom of the Perl Monks concerning the following question:
$padded = sprintf("%-10s", $string); #or use pack "A10" $padded = s/( +)$/"0" x length $1/e;
$padded = reverse sprintf("%010s", scalar reverse $string);
$padded = "0" x 10; substr($padded, 0, length $string) = $string;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: clever zero _right_ pad?
by tye (Sage) on Sep 15, 2000 at 20:40 UTC | |
|
Re (tilly) 1: clever zero _right_ pad?
by tilly (Archbishop) on Sep 15, 2000 at 21:08 UTC | |
|
Re: clever zero _right_ pad?
by jimt (Chaplain) on Sep 15, 2000 at 20:47 UTC | |
|
Re: clever zero _right_ pad?
by Fastolfe (Vicar) on Sep 15, 2000 at 20:41 UTC | |
|
Re: clever zero _right_ pad?
by fundflow (Chaplain) on Sep 15, 2000 at 20:49 UTC |