How to find if values of an array are the keys of hash in Perl? How to find if values of an array are the keys of hash in Perl? arrays arrays

How to find if values of an array are the keys of hash in Perl?


This should do it:

my @array = qw(a b c) ;my %hash = ( a => 1 , b => 2 ) ;my @result = grep { exists $hash{$_} } @array ;