%a = ( one=>1, two=>2, three=> 3 ); %b = ( two=>'two', three=>'three', four=>'four'); #### if (exists $a{one}) { print "\%a has 'one' for a key" } #### print join(",", keys %a); # prints "one,two,three" #### my @common_keys; foreach my $key (keys %a) { if (exists $b{$key}) { print "\%a and \%b have key '$key' in common\n"; push @common_keys, $key; } } #### my @common_keys = grep { exists $b{$_} } keys(%a); #### $x = \%a; $y = \%b; #### my @common_keys = grep { exists $y->{$_} } keys( %{ $x } );