At 8:03 PM -0600 3/20/11, Chris Stinemetz wrote:
Jim,
Thanks for your feedback. I am actually trying to sum up all rlptxat
elements that have the same cell, sect, and chan elements in the
array. I hope this clarifies.
No, it doesn't. What is a "rlptxat" element? Where do they come from.
You can define a multiple-level hash with three nested keys (cell,
sect, chan) to hold the sum of all elements with the same key values
(a triple):
my %sum;
Find values of cell, sect, and chan:
$cell = ?
$sect = ?
$chan = ?
Add the value with these keys to the sum:
$sum{$cell}{$sect}{$chan} += ?
Iterate over the result:
for my $cell ( sort keys %sum ) {
for my $sect ( sort keys %{$sum{$cell}} ) {
for my $chan ( sort keys %{$sum{$cell}{$sect}} ) {
print "Value of sum($cell,$sect,$chan) is
$sum{$cell}{$sect}{$chan}\n";
}
}
}
Good luck!
--
Jim Gibson
j...@gibson.org
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/