|We don't bite newbies here... much|
Concatenate anonymous hash refby wanna_code_perl (Pilgrim)
|on Oct 14, 2008 at 16:45 UTC||Need Help??|
wanna_code_perl has asked for the
wisdom of the Perl Monks concerning the following question:
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.