in reply to Re: merging two hashes and updating the 1st hash keys.
in thread merging two hashes and updating the 1st hash keys.

Use of exists in the grep, not defined may be clearer. defined implies that there is an element in %h1 that matches the key, but that it may be undef. exists tests for the existence of the element with no implication that it should already be there or that it may be set to any particular value.

It's interesting to note though that defined doesn't cause elements in %h1 to be autovified as might be expected.


True laziness is hard work
  • Comment on Re^2: merging two hashes and updating the 1st hash keys.