while(<DATA>){ ($first, $last)=/(\w+) (\w+)/; # Could be: (\S+) (\S+)/ print "$last, $first\n"; } __DATA__ First Last