my ($col1, $col2, $col3) = generate_data(); if (! defined $hash{$col1}) { $hash{$col1} = [ 0, 0 ] } $hash{$col1}[0] += $col2; $hash{$col1}[1] += $col3;