for my $key (keys %hash) { if (exists $hash{$key}{FILE1}) { if (exists $hash{$key}{FILE2}) { # Key exists in both files } else { # Key exists only in file 1 } } else { # Key exists only in file 2 } } #### foreach my $key (keys (%hasha)) { if (my @temp = grep( /$key/, @prevarray ) ) { push(@{$hasha{$key}},$value); next; } else { push (@{$hashb{$key}},$value); next; } } #### foreach my $key (keys (%hasha)) { if (my @temp = grep( /$key/, @prevarray ) ) { push(@{$hasha{$key}},$value); next; } else { push (@{$hashb{$key}},$value); next; } } #### foreach my $key (keys (%hasha)) { if (my @temp = grep( /$key/, @prevarray ) ) { push(@{$hasha{$key}},$value); next; } else { push (@{$hashb{$key}},$value); next; } }