perl -e '$a = "abc print pqr scan xyz"; print "matched\n" if($a =~ /(?=.*(?=scan))(?=.*(?=print))/)' matched