Put all the data you'll need in $allkeys and then just pull it all out with values.
my $allkeys; for ( @{ $allusers } ) { my $user = $_->{'user'}; if ( !exists $allkeys->{$user} ) { $allkeys->{$user} = { %{ $_ } }; } else { my $refAttributes = $allkeys->{$user}; $refAttributes->{'amount'} += $_->{'amount'}; $refAttributes->{'duration'} += $_->{'duration'}; } } my $finalArray = [ values %{ $allkeys } ];
In reply to Re: Ways to group elements of an AoH
by kyle
in thread Ways to group elements of an AoH
by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |