RE: foreach loop
- From: cstinemetz@xxxxxxxxxxxxxxxxxxxxxxxxx (Chris Stinemetz)
- Date: Tue, 22 Mar 2011 15:24:33 -0600
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
Jim@xxxxxxxxxx
.
- Follow-Ups:
- Re: foreach loop
- From: Jim Gibson
- Re: foreach loop
- References:
- Re: foreach loop
- From: Shlomi Fish
- RE: foreach loop
- From: Jim Gibson
- RE: foreach loop
- From: Jim Gibson
- Re: foreach loop
- Prev by Date: Re: Newbie needs help
- Next by Date: Re: shift oo
- Previous by thread: Re: foreach loop
- Next by thread: Re: foreach loop
- Index(es):
Relevant Pages
|