my %hash = @allwords; #puts array in hash to search / compare. if (exists $hash{'word1' && 'word2' && 'word3'}) { ...do stuff ; } #### if ( grep { $_ eq 'word1' && 'word2' } @allwords ) { ...do stuff; }