my %totals; while ( ) { chomp; /(^[a-z].*$)/i or $totals{$1} += $_; }