in reply to grep for array-of-strings from an array-of-strings

Updated Oops! I mistook any() for all(). Fixed thusly

This is easy - your grep condition should return true if all of the search strings are found within the string being tested. In this case I created a function which tests a string against a criteria list and returns false if any don't match. Then I modified your grep so that it tests each element against all the criteria.

sub indexall { -1 == index $_, $_[0] and return 0 for @_[1 .. $#_]; re +turn 1 } if (@newArray = grep indexall($_, @searchCriteria), @largeArray) { print @newArray; }

Replies are listed 'Best First'.
Re: Re: grep for array-of-strings from an array-of-strings
by zby (Vicar) on Apr 09, 2003 at 19:55 UTC
    I think he wants not 'any' but 'each'.