while ($line=) { my @items = split /\s+/,$line; $items[1] =~ s/\-/\n$items[0] /g; print join " ",@items,"\n"; }