Amoe has asked for the wisdom of the Perl Monks concerning the following question:
Obviously this wouldn't be very useful, but the hashes contain *swishes hands* top secret data. (Not really top secret; I just prefer to remain mysterious). So when I'm removing duplicates from this array, here's the crux of the matter. I need to remove the whole hash if only the 'bob' field is a duplicate, regardless of whether the 'alice' field is also a duplicate. So:@array = [{bob => 'value1', alice => 'value2'}, {bob => 'othervalue1', + alice => 'othervalue2'}]; # and so on for loads of elements...
The second hash would be considered a duplicate of the first, the two bob fields being equal, and removed. Anyone up for suggesting how to do this? I'm pretty stumped.$hash = {bob => 'I am a value', alice => 'You're not a value.'}; $hash2 = {bob => 'I am a value', alice => 'You bloody well aren't a va +lue!'}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Removing duplicate hashes based on only one key
by merlyn (Sage) on Sep 20, 2001 at 20:16 UTC | |
by dragonchild (Archbishop) on Sep 20, 2001 at 20:31 UTC | |
by chromatic (Archbishop) on Sep 20, 2001 at 21:21 UTC | |
by arturo (Vicar) on Sep 20, 2001 at 21:24 UTC | |
|
Re: Removing duplicate hashes based on only one key
by roaima (Initiate) on Sep 20, 2001 at 20:32 UTC |