Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^3: Get just the unique value

by CountOrlok (Friar)
on Apr 05, 2013 at 17:28 UTC ( #1027180=note: print w/ replies, xml ) Need Help??

in reply to Re^2: Get just the unique value
in thread Get just the unique value

It isn't clear what you want for output. You want to remove entries in the original data where type is duplicated, it seems, but how do you want to handle the case where reference or name is different? Which entry in the arrayref do you want to choose?

Comment on Re^3: Get just the unique value
Replies are listed 'Best First'.
Re^4: Get just the unique value
by Anonymous Monk on Apr 05, 2013 at 17:45 UTC
    OK, let me try again, I have a data structure like this:
    my $data = [ { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Plastic' }, { 'type' => 'Plastic' }, { 'type' => 'Plastic' }, { 'type' => 'Plastic' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, ];
    I need to process this array and filter out the duplicated ones:
    my $res; for my $entry (@$data) { #$entry->{type} = [] unless exists $entry->{type}; push @$res, $res{$entry->{type}}; } print Dumper @$res;
    I just cant get it to work.
      Use the code hdb posted

        Yes, I think it should work.

      I think if you feed your new structure to some of the proposals it will work...

        I tested, none of them work unfortunately, I will look also where.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2015-11-27 02:01 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (712 votes), past polls