my %hash = @allwords; #puts array in hash to search / compare. #### ( 'word1' => 'word2', 'word3' => undef, ) #### $ perl -MData::Dump -e '@a = qw{b c a}; %h = @a; dd \%h' { a => undef, b => "c" } #### my %hash = map { $_ => 1 } @allwords; #### $ perl -MData::Dump -e '@a = qw{b c a}; %h = map { $_ => 1 } @a; dd \%h' { a => 1, b => 1, c => 1 } #### if (exists $hash{'word1' && 'word2' && 'word3'}) { ... #### $ perl -E 'my $x = "a" && "b" && "c"; say $x' c #### if ( grep { $_ eq 'word1' && 'word2' } @allwords ) { ... #### $ perl -E '$_ = "a"; my $x = $_ eq "a" && "b"; say $x' b #### $ perl -MO=Deparse -e 'grep { $_ eq "word1" && "word2" } @a' grep {'word2' if $_ eq 'word1';} @a; -e syntax OK $ perl -MO=Deparse,-p -e 'grep { $_ eq "word1" && "word2" } @a' grep({(($_ eq 'word1') and 'word2');} @a); -e syntax OK #### $ perl -E 'my @x = qw{b c a}; say scalar grep { /^(?:a|b|c)$/ } @x' 3 $ perl -E 'my @x = qw{x y z}; say scalar grep { /^(?:a|b|c)$/ } @x' 0 $ perl -E 'my @x = qw{x c y a b z}; say scalar grep { /^(?:a|b|c)$/ } @x' 3 #### my $regex = ...; if (@matchwords == grep { /$regex/ } @allwords) { ...