use strict; use warnings; my( @p_types ) = qw/ pam php kph /; my( @c_types ) = qw/ cam c1 c2 /; my @true = qw/ pam c2 /; my @false = qw/ cam c2 /; my %p_hash; @p_hash{@p_types} = (); my %c_hash; @c_hash{@c_types} = (); print "\@true is ", ( qualify( \@true, \%p_hash, \%c_hash ) ) ? "True.\n" : "False.\n"; print "\@false is ", ( qualify( \@false, \%p_hash, \%c_hash) ) ? "True.\n" : "False.\n"; sub qualify { my( $test_aref, $p_href, $c_href ) = @_; if( grep{ exists $p_href->{$_} } @{$test_aref} and grep{ exists $c_href->{$_} } @{$test_aref} ) { return 1; } else { return 0; } }