use strict; use warnings; my $file = 'scott.d3'; my $FhIn; my $all_yr_tot = 0; 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"; $all_yr_tot += $yr_tot; } } close $FhIn or die $!;