foreach my $key ( sort keys %hash1 ) { print $hash1{$key} - $hash2{$key}, "\n"; }