while ( my ($key, $value) = each(%hash1) ) { while ( my ($key1, $value1) = each(%hash2) ) { if ($value eq $value1) { print "\n$key => $value\n is equal with\n"; print "$key1 => $value1\n" } } print "$key => $value\n"; }