while() { if (/^(\w+.+?(?:AM|PM))\s+(\w+.+?(?:AM|PM))/) { print $1,"\n", $2, "\n___\n"; } } __DATA__ ...