Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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?
[Corion]: I hope you had a good weekend!
[marto]: jetlag has really done a number on the kids, it's been a tough week
choroba played with the band on Saturday, so Sunday was very sleepy
[choroba]: managed to release Syntax::Construct with 5.28 support in the night, though
[Corion]: choroba: Whee ;)
[Corion]: marto: Ouch - I would've thought that kids adapt much better, but that's obviously not the case...
[marto]: well, their mother let them sleep till 15:00 & 12:00 last week, which didn't help them adjust :P
[Corion]: I was "productive" over the weekend in the sense that I revived my old "Perlmonks on SQLite" code, which likely means I can get a test instance back up running on my webhost. Small steps :)
[Corion]: marto: Ow, no, that doesn't help at all :)
[choroba]: Related to the new release, anyone could explain this or this tester report?

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2018-06-25 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?