sub fold { my $self = shift; my %h; my @groups = @{ $self->{groups} }; for ( @{ $self->{data} } ) { push @{ $h{ join $;, @$_{ @groups } } }, $_; } $self->{data} = [ map { my $x; @$x{ @groups } = @{ $h{$_}->[0] }{ @groups }; for ( @{ $h{$_} } ) { $x->{views} += $_->{views}; $x->{clicks} += $_->{clicks}; } $x; } keys %h ]; }
In reply to Re: Array Folding
by borisz
in thread Array Folding
by BarMeister
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |