in reply to using grep to match more than two words

A subroutine inspired by the responses from naikonta and pgor but greping using exists against an on-the-fly hash constructed from the elements of @$raAll.

sub isTargetInAll { my ($raAll, $raTarget) = @_; return @$raTarget == grep { exists { map { $_ => 1 } @$raAll }->{$_} } @$raTarget; }

I think that should be reliable as long as @$raTarget doesn't contain duplicates; if you were looking for a Sun and two Moons you would get a false positive if @$raAll had a Sun and just one Moon.

Cheers,

JohnGG