Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Unique list of hashes

by parv (Parson)
on Mar 02, 2015 at 11:41 UTC ( [id://1118398]=note: print w/replies, xml ) Need Help??


in reply to Unique list of hashes

Make a key out of combined values to search for uniqueness ...

@uniq = grep !$seen{ join '' , sort values %{ $_ } }++ , @list ;

Replies are listed 'Best First'.
Re^2: Unique list of hashes
by Anonymous Monk on Mar 02, 2015 at 11:57 UTC
    Make a key out of combined values to search for uniqueness ... @uniq = grep !$seen{ join '' , sort values %{ $_ } }++, @list;

    So these are all the same?

    my @list = ( { foo=>'bar', quz=>'baz' }, { abc=>'bar', def=>'baz' }, { ijk=>'ba', xyz=>'rbaz' }, { r=>'ba', s=>'rba', t=>'z' }, { x=>'barbaz' }, );

      Using a delimiter that cannot appear in the values would be useful... like a pipe or such.

      Nope, not all are same as you already know. hdb has already given slightly complicated method to satisfy your situation.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1118398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-23 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found