while (my $line=<>) { $line =~ /(\S+)\s+(.+?)\s*((?:Last|Never).+)/; print "$1::$2::$3\n"; }