in reply to Re^2: Need advice on hashes and methods
in thread Need advice on hashes and methods

Yeah, I suppose that would work, too. The code sample I gave you would work (and is a little more efficient for large lists, since you're only iterating through the list of keys once, instead of twice.) Essentially you want to eliminate the intersection of the two hashes, I think -- and either way will work.

Update: As you pointed out below, the first foreach removes elements from the first hash, so the second foreach fails to detect matches. Better stick with the single-pass solution. Thanks for pointing that out! :)

  • Comment on Re^3: Need advice on hashes and methods

Replies are listed 'Best First'.
Re^4: Need advice on hashes and methods
by tom2112 (Novice) on Aug 15, 2006 at 14:05 UTC
    Ooops. My idea wouldn't work, since the first loop is destructive of the first hash, by the time it got to the second hash, it would think that they were all new members. Your single loop should do it correctly, now that I really think about it!