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; } }