- or download this
# Modifies @array in-place.
foreach (@array) {
$_ = sprintf($format, $_);
}
- or download this
# Copies to a second array while formatting.
my @formatted = map { sprintf($format, $_) } @array;
- or download this
# Same as last, but without using "map".
my @formatted;
for (0..$#array) {
$formatted[$_] = sprintf($format, $array[$_]);
}
- or download this
foreach (@formatted) {
print($_, "\n");
}