while( my( $key, $val1 ) = each( %hash1 ) ) { my( $val2 ) = $hash2{$key}; # Do something with $key, and $val1, $val2. }