in reply to Assign (key, value) to a hash w/o clobbering hash
When merging two hashes, I mostly recreate the merged hash from the two other hashes:
my %actual = (%defaults,%args);
The order of %hash1 and %hash2 determines, which keys/values take precedence - most times, I want the defaults to have lower precedence than the supplied parameters. Of course, here, clobbering is what is wanted. I'm not aware of a callback-based solution to merge hashes like reduce does for lists.
|
|---|