my $to = 0; for (@m) { $m[$to++] = $_ if $_ ne "\n"; } splice @m, $to;