my %words; ++$words{$_} for /\w+/g; for ( [qw( Fred Flinstone )], [qw( Barney Rubble )], [qw( Joe Rockhead )], ) { next if @$_ != grep $words{$_}, @$_; print("matched @$_\n"); }