if (($string=~m/abc/i && $string=~m/xyz/i)) { print "\nMatched"; } #### if ($string=~m#(abc).*?(xyz)#i) { print "\nfound"; }