for my $key_hash1 (sort {lc($a) cmp lc($b) } keys %{$hash1} ) { if( ! exists $hash2->{$key_hash1} ) { print "Hash1 contains unit '$key_hash1' but hash2 has no such unit\n"; next; } #### for my $key_hash2 (sort {lc($a) cmp lc($b) } keys %{$hash2} ) { if( ! exists $hash1->{$key_hash2} ) { print "Hash1 contains unit '$key_hash2' but hash1 has no such unit\n"; } } #### if( $hash1->{$key_hash1} ne $hash2->{$key_hash1} ) { print "Both hashes have '$key_hash1' as a unit ", "but hash1's value is '$hash1->{$key_hash1}' ", "and hash2's value is '$hash2->{$key_hash1}'\n"; } #### for my $key_hash1 (sort {lc($a) cmp lc($b) } keys %{$hash1} ) { if( ! exists $hash2->{$key_hash1} ) { print "Hash1 contains unit '$key_hash1' but hash2 has no such unit\n"; next; } for my $key_hash1_tier2 (sort {lc($a) cmp lc($b) } keys %{$hash1->{$key_hash1}} ) { if( ! exists $hash2->{$key_hash1}{$key_hash1_tier2} ) { print "Hash1 $key_hash1 contains unit '$key_hash1_tier2' but hash2 has no such unit\n"; next; } if( $hash1->{$key_hash1}{$key_hash1_tier2} ne $hash2->{$key_hash1}{$key_hash1_tier2} ) { print "Both hashes have '$key_hash1'-'$key_hash1_tier2' as a unit ", "but hash1's value is '$hash1->{$key_hash1}{$key_hash1_tier2}' ", "and hash2's value is '$hash2->{$key_hash1}{$key_hash1_tier2}'\n"; } } }