use strict; use warnings;
use List::Util 'all';
# see below for how to properly create your hash
my %words = (
foo => 1,
bar => 1,
baz => 1,
qux => 1,
);
my @must_exist = (
'bar',
'qux',
);
my $all_found = all { exists $words{ $_ } } @must_exist;
if ( $all_found ) {
...
}
####
my %hash = @allwords; #puts array in hash to search / compare.
####
@array = ('foo', 'bar', 'baz', 'qux');
%hash = map { $_ => 1 } @array;
####
if (exists $hash{'word1' && 'word2' && 'word3'}) {
...do stuff ;
}
####
if ( exists $hash{'foo'} and exists $hash{'bar'} ) {
...
}
####
if ( grep { $_ eq 'word1' && 'word2' } @allwords ) {
...do stuff;
}