Jim,
I have another question.
How do I sort the results so it is from smallest to largest starting with
$cell,$sect,$carr?
Thanks again for all you help. I am gaining a much better understanding.
This is what I got:
#!/usr/bin/perl
use warnings;
use strict;
#my $filepath = 'C:/temp/PCMD';
#my $filepath = 'C:/cygwin/home/cstinemetz/perl_programs/1.EVDOPCMD';
# my $outfile = 'output.txt';
#open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
# open my $out, '>', $outfile or die "ERROR opening $outfile: $!";
my %sum;
#my @records = ();
while (<DATA>){
next unless /;/;
chomp;
my @data = split /;/;
my($cell,$sect,$chan,$carr,$rlptxat1,$rlptxat2,$rlptxat3,$rlptxat4,$dist,$precis)
= @data[31,32,38,39,44,45,46,47,261,262];
$carr =
( $chan == 75 ) ? 2 :
( $chan == 1025 ) ? 2 : 1 ; #nested ternary operator
$dist =
( length( $dist ) > 1 ) ? $dist/6.6/8/2*10/10 : 0 ;
$sum{$cell}{$sect}{$carr}{$dist} += $rlptxat1 += $rlptxat2 += $rlptxat3
+= $rlptxat4 || 0 ; }
for my $cell ( sort keys %sum ) {
for my $sect ( sort keys %{$sum{$cell}} ) {
for my $carr ( sort keys %{$sum{$cell}{$sect}} ) {
for my $dist ( sort keys
%{$sum{$cell}{$sect}{$carr}} ) {
print "$cell\t $sect\t $carr\t $dist\t" .
$sum{$cell}{$sect}{$carr}{$dist} . "\n";
}
}
}
}
And this is the current output:
10 2 1 0.710227272727273 439
100 1 1 0 469
100 2 1 0 3207
101 3 1 0 96
102 3 1 0 1623
107 1 1 0 48
109 2 1 0 49
11 2 1 0 48
110 3 1 0.681818181818182 49
114 3 1 0 48
121 2 1 2.78409090909091 3628
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/