in reply to Re: Intersect two hashes
in thread Intersect two hashes
The perlfaq describes intersection of two arrays. I feel this is a better solution for intersecting arrays than what is mentioned in the faq.
However, I am looking to intersect hashes. What I am doing right now is :
Is there a better way to do this?foreach (keys %hash1){ $intersected_hash{$_} = $hash1{$_} if exists $hash2{$_}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Intersect two hashes
by Corion (Patriarch) on Jun 10, 2007 at 20:00 UTC | |
by ysth (Canon) on Jun 11, 2007 at 07:00 UTC | |
by GrandFather (Saint) on Jun 10, 2007 at 21:19 UTC | |
|
Re^3: Intersect two hashes
by blazar (Canon) on Jun 10, 2007 at 21:14 UTC | |
by HarshaHegde (Sexton) on Jun 11, 2007 at 16:03 UTC |