Hi! is there a regular expression I can use instead of my line of code 'if ( $county eq 26005 )' ?
Also, for lines that match '$county eq 26005' I need to count/total the corresponding '$yr_tot' field on the same line. How do you total a $scalar column in perl? there doesn't appear to be a function similar to sql's 'count'.
Thanks!
Scott
use strict;
use warnings;
my $file = 'scott.d3';
my $FhIn;
open $FhIn, '<', $file or die "Could not open $file: $!";
while( my $line = <$FhIn> ) {
my ($county, $year, $yr_tot) = split ' ', $line;
if ( $county eq 26005 ) {
print "$county : $yr_tot\n";
}
}
close $FhIn or die $!;
20050201 Janitored by Corion: Added formatting