in reply to Re: Summing column values
in thread Summing column values
(defined $hash{$array[0]}{$id}) ? ($hash{$array[0]}{$id} += $array[2]) : ($hash{$array[0]}{$id} = $array[2]);
That's more complicated than is necessary. Perl's clever enough to know that if you add a number to an undefined variable, to treat that var as 0. This would suffice:
$hash{$array[0]}{$id} += $array[2];
|
|---|