Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Combining / Merging two Ho(H|A)s

by jdporter (Canon)
on Feb 21, 2006 at 23:22 UTC ( #531832=note: print w/replies, xml ) Need Help??


in reply to Combining / Merging two Ho(H|A)s

You didn't say what should happen when there are existing values in the two hashes, but their types are different. For example,

%h1 = ( foo => 1, ); %h2 = ( foo => { bar => 2, }, );
Do you have reason to believe this won't happen?

We're building the house of the future together.

Replies are listed 'Best First'.
Re^2: Combining / Merging two Ho(H|A)s
by jkva (Chaplain) on Feb 22, 2006 at 05:41 UTC
    Very very good point. It is possible. I'd say the first hash's value should be overwritten by the second one.
    GrandFather's code can be easily changed to check for REF differences and act accordingly.

      Right; but I would definitely look into Hash::Merge (Roy_Johnson's suggestion).

      We're building the house of the future together.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://531832]
help
Chatterbox?
[shmem]: msh210: 'tis about time to tell the sad truth to perl5porters - via perlbug
[msh210]: probably whoever wrote that actually knows the truth
[shmem]: msh210: you can save the perlbug text in a file and send that via your mail agent of choice
[msh210]: hm, okay, I'll try, thanks
[shmem]: ...not as an attachment, it's probably better to c&p that into the mail body

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-04-24 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.