On 3/23/11 Wed  Mar 23, 2011  10:02 AM, "Chris Stinemetz"
<cstinem...@cricketcommunications.com> scribbled:

In addition to the missing semicolon, the declaration of %sum must appear
before it is used, i.e. before the while(<DATA>) loop. The line adding
values of $rlptxat1 to the sum must appear inside the while loop, not after
it.

Run this program on your data:

#!/usr/local/bin/perl

use warnings;
use strict;

my %sum;
while (<DATA>){

  next unless /;/;
  chomp;
  my @data = split /;/;
  my($cell,$sect,$chan,$carr,$rlptxat1,$dist,$precis) =
      @data[31,32,38,39,44,261,262];

  $sum{$cell}{$sect}{$chan} += $rlptxat1 || 0;
}

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";
    }
  }
}



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to