in reply to regular expressions

I don't understand why you want to use a regular expression instead of a simple equality operator. Because $county is a number, however, you should be using == instead of eq.

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