Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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?
[ambrus]: wait. I understand no wife and children, but how do you not have to pay for a house?
[hippo]: I had a low-paid job about 20 years ago and seriously considered going down to a 3-day week. Would have worked 60% of the time for about 80% of the cash.
[Corion]: ambrus: Well, I pay rent, but don't own a house with variable/ unforeseeable costs
[hippo]: The thesholds/benefits balance at the time was nuts.
[hippo]: But that doesn't last because, you know ... politicians. :(
[Corion]: hippo: Yeah, if you still get enough money to get by and don't have expensive hobbies or other fixed costs that can work out well
[ambrus]: ah good. I pay only rent too. but that still costs significant money.
[Corion]: ambrus: Yes, but that is already budgeted for

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2017-09-21 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (249 votes). Check out past polls.

    Notices?