in reply to Re: How to loop over groups
in thread How to loop over groups
@a = (['a',1],['a',2],['b',3],['b',4]); # "db read" my $old; my $total = 0; # init foreach my $row (@a) { if ($old && $old ne $row->[0]) { print "$old: $total\n"; # finish row block $total = 0; # init print "Section $row->[0]\n"; } $total += $row->[1]; # processrow block print "$row->[1]\n"; $old = $row->[0]; # set temp variable } print "$old: $total\n"; # finish row block
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: How to loop over groups
by RMGir (Prior) on Apr 02, 2002 at 13:06 UTC |