- or download this
$padded = sprintf("%-10s", $string); #or use pack "A10"
$padded = s/( +)$/"0" x length $1/e;
- or download this
$padded = reverse sprintf("%010s", scalar reverse $string);
- or download this
$padded = "0" x 10;
substr($padded, 0, length $string) = $string;