in reply to regular expressions
To add up all the totals, simply declare a variable outside your loop and add each one.
my $total = 0; while( my $line = <$FhIn> ) { my ($county, $year, $yr_tot) = split ' ', $line; if ( $county == 26005 ) { print "$county : $yr_tot\n"; $total += $yr_tot; } }
|
|---|