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.