# Takes a string and a list of REs. Returns true or false # depending on whether all of them match. sub match_all { my $str = shift; foreach my $re (@_) { return 0 unless $str =~ /$re/; } return 1; } #### if (match_all($str, split(/\s+/, $search_str))) { print "All of them matched\n"; } #### OUTER: { foreach my $animal (@animals) { last OUTER if $str !~ /$animal/; } print "Matched all of them!"; }