in reply to Array Folding

Here is my try: untested. propably you need to sort the keys for your output. And the keys in groups must match the data keys. say date and campain_id in your example.
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 ]; }
Boris

Replies are listed 'Best First'.
Re^2: Array Folding
by BarMeister (Beadle) on Mar 07, 2006 at 14:53 UTC
    Thanks everyone for the feedback :-)