Keep It Simple, Stupid | |
PerlMonks |
Re: Hash Multiple values for a key-Filtering unique values for a key in hashby kcott (Archbishop) |
on May 23, 2017 at 05:59 UTC ( [id://1190930]=note: print w/replies, xml ) | Need Help?? |
G'day rahulme81, That's a FAQ: How can I remove duplicate elements from a list or array?. To keep the values unique for a specific key, without removing duplicates from the values of other keys, you'll need to clear the %seen hash for each arrayref value. Here's how you might implement that:
Output:
Note that the input shown in your OP has the two unique values 'Beacon' and 'Becon', but your expected output only has 'Becon': I suspect a typo. Beyond that, my actual output matches your expected output. See also: values. — Ken
In Section
Seekers of Perl Wisdom
|
|