while( my( $key1, $val1 ) = each( %hash1 ) ) { my( $key2, $val2 ) = each( %hash2 ); # do something with $key1, $key2, $val1, and $val2 }