Hi Chris,
On Sunday 20 Mar 2011 05:43:38 Chris Stinemetz wrote:
> I am trying to code a foreach loop, that will add all occurrences of the
> element rlptxat that have the same elements cell, sect and chan.
>
> My failed attempt can be located in between the ### lines.
>
If I understand your cod
> "SF" == Shlomi Fish writes:
>> my @records;
>>
>> my @lines = read_file( $filepath );
>>
>> chomp @lines;
>>
SF> You should read the file line-by-line, using:
SF> < $fh >
SF> Not slurp it.
there is no reason to read it line by line. it is small enough to
slurp. sl
So back to the question. How can I nest this foreach loop correctly to add all
occurrences of the element rlptxat that have the same elements cell, sect and
chan in the array?
$record{rlptxat} = ( length($record{rlptxat})> 1 ) ? $record{rlptxat}{cell,
sect, chan, dist}++ : '' ;
Thank you very
At 8:31 AM -0600 3/20/11, Chris Stinemetz wrote:
So back to the question. How can I nest this foreach loop correctly
to add all occurrences of the element rlptxat that have the same
elements cell, sect and chan in the array?
$record{rlptxat} = ( length($record{rlptxat})> 1 ) ?
$record{rlptxat
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.
Thank you,
Chris
-Original Message-
From: Jim Gibson [mailto:jimsgib...@gmail.com]
Sent: Sunday, March 20, 2011 5:
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
δΊ 2011-3-21 13:33, Jim Gibson ει:
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";
}