while () { s/^\s+//; s/\s+$//; if (!/\s/) { $_ .= ; redo; } my ($title, $status) = ( split /\s+/ )[0,5]; print "$title $status\n"; }