for (split ' ', $sequences) { if (/\Q$quart1/ and /\Q$quart2/) { print "Found both in $_\n"; } }