in reply to Re: grep for array-of-strings from an array-of-strings
in thread grep for array-of-strings from an array-of-strings

And here is some code for it: my $criteria = join "|", @searchCriteria; and then use it in the regex like that: /$criteria/

Update: I realized that the 'and' case is much more difficult that the 'or' case that I presented. I would use eval for it:  my $criteria = join "/ and /", @searchCriteria; $criteria = "/$criteria/"; and then use it like this grep {eval $criteria}. Which is just your second code dynamically generated.