in reply to merging two hashes and updating the 1st hash keys.
This achieves your goal. But it still loops, albeit that the loop is hidden:
%hash1 = qw( a b c d e f ); %hash2 = qw( a J e K y z ); @sharedKeys = grep defined( $hash2{ $_ } ), keys %hash1; @hash1{ @sharedKeys } = @hash2{ @sharedKeys };; print %hash1;; e K c d a J
|
|---|