use strict; use warnings; my $file = 'scott.d3'; my $FhIn; open $FhIn, '<', $file or die "Could not open $file: $!"; my $total; while( my $line = <$FhIn> ) { my ($county, $year, $yr_tot) = split ' ', $line; if ( $county == 26005 ) { # - or - # if ( $county eq '26005' ) { print "$county : $yr_tot\n"; $total += $yr_tot; } } close $FhIn or die $!; print "Total yr_tot's: $total\n";