in reply to using grep to match more than two words

My solution is almost like naikonta's, except I'm removing from the list of required entries instead of just counting matches. This allows you to terminate early once you've found everything required.

sub containsAll { my ($arrEverything, $arrRequire) = @_; my %stillRequired = map { $_ => 1 } @$arrRequire; for my $entry ( @$arrEverything ) { if ( delete($stillRequired{$entry}) ) { last unless %stillRequired; } } return %stillRequired ? 0 : 1; }

Call as containsAll(\@arr1,['Sun','Moon'])

Feel free to take the concept and make it into your single statement requirement, since I don't see how anything maintainable can come of that kind of requirement.

pg