my %hash2; undef @hash2{qw(a b c)}; my %hash1; undef @hash1{qw(c d e)}; undef @hash2{keys %hash1}; print "$_ ",defined($hash2{$_})?"def\n":"undef\n" for keys %hash2;