use strict; use warnings; my $total; while() { my ($county, $year, $yr_tot) = split; $total += $yr_tot if $county =~ /26005/; } print "Total for county 26005: $total\n"; __END__ 26005 2004 1 26005 2004 2 26005 2004 3 26004 2004 1 26003 2004 1