in reply to Re^3: Get just the unique value
in thread Get just the unique value
OK, let me try again, I have a data structure like this:
I need to process this array and filter out the duplicated ones: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 just cant get it to work.my $res; for my $entry (@$data) { #$entry->{type} = [] unless exists $entry->{type}; push @$res, $res{$entry->{type}}; } print Dumper @$res;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Get just the unique value
by CountOrlok (Friar) on Apr 05, 2013 at 18:18 UTC | |
by hdb (Monsignor) on Apr 05, 2013 at 18:35 UTC | |
Re^5: Get just the unique value
by hdb (Monsignor) on Apr 05, 2013 at 18:22 UTC | |
by Anonymous Monk on Apr 05, 2013 at 18:24 UTC | |
by CountOrlok (Friar) on Apr 05, 2013 at 18:27 UTC | |
by Anonymous Monk on Apr 05, 2013 at 18:59 UTC | |
by CountOrlok (Friar) on Apr 05, 2013 at 19:02 UTC | |
by hdb (Monsignor) on Apr 05, 2013 at 19:34 UTC | |
by hdb (Monsignor) on Apr 05, 2013 at 19:43 UTC |
In Section
Seekers of Perl Wisdom