my %sums; for( my $i = 0; $i < $lines; ++$i ) { $sums{$data[$i][1]} += $data[$i][3]; }