P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello Monks, What is the most elegant way to combine two hashes by reference? I basically want to do this:
Obviously, the concatenation operator won't have the desired effect. And I know I can manually concatenate the two hashes, with, say:
Overwriting values is expected and OK in my application. However, is there a more elegant (and time/memory efficient) solution? The hash refs are a return from a function. I want to concatenate the return from successive calls. Update: Thanks for the good ideas! It turns out it is cleaner for me to just pass the reference to my helper functions, and let them modify it. I was trying to avoid the extra parameter, but looks like that will be the easiest to maintain in this case. In reply to Concatenate anonymous hash ref by wanna_code_perl
|
|