Syntactic Confectionery Delight | |
PerlMonks |
Concatenate anonymous hash refby wanna_code_perl (Friar) |
on Oct 14, 2008 at 16:45 UTC ( [id://717037]=perlquestion: print w/replies, xml ) | Need Help?? |
wanna_code_perl has asked for the wisdom of the Perl Monks concerning the following question: 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.
Back to
Seekers of Perl Wisdom
|
|