while () { if (/^(\w+)\s+(\w+)$/) { print "<$1><$2>\n"; } else { print "Line $. didn't match\n"; } }