{ local $/ = 'Query= '; while (<$filehandle>) { print "$1\t$2" if / \A (\S+) .*? ^ > (\S+) /msx; } }