for my $line (@lines) { my @fields = split ' ', $line; $fields[1] .= ' ' x (50 - length $fields[1]); $line = join(' ', @fields); }