>>No, it doesn't. What is a "rlptxat" element? Where do they come from.
"rlptxat" is just an element indexed at 44 that has a value, in which I would
like to sum up, when it has the same elements "cell" "sect" and "carr" in the
record.
I hope this helps
Thank you,
Chris
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
[email protected]
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/