in reply to combining hashes based on key values
You've got several smaller chores that add up to the solution to your problem. Tackling the small chores will help you to solve the bigger picture.
In %out_hash, 'jibber jabber' holds those id's that are found in both 'jibber' and in 'jabber'. This is an intersection.
You also want %out_hash to keep the id's from "jibber" that are unique to "jibber" within the key named "jibber", and the same for "jabber". This is the symmetric difference.
You may get a start by looking at List::Compare, and by reading perlfaq4 under the section called "How do I compute the difference of two arrays? How do I compute the intersection of two arrays?" For your purposes, your input hashes are simply sparse arrays. Treat them as lists of id's indexed by hash keys instead of array indices, and you'll find your way around the problem. This response assumes you already know your way around Perl's references and complex datastructures. If you need help tackling those too just let us know where you need clarification.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: combining hashes based on key values
by punkish (Priest) on Jun 08, 2005 at 04:09 UTC | |
by davido (Cardinal) on Jun 08, 2005 at 05:00 UTC |