if ($sentence =~ /foo/gis) { if ($sentence =~ /bar/gis) { # now do something with the sentence } }