foreach my $j ($col_start .. $#column) { my $nIndex = $n[$j]; $x[$nIndex][$j] = $column[$j]; $x_tot[$j] += $x[$nIndex][$j]; $n[$j]++; }