foreach my $j ($col_start .. $#column) { $n[$j] += 0; # add this to remove warning msg $x[$n[$j]][$j] = $column[$j]; $x_tot[$j] += $x[$n[$j]][$j]; $n[$j]++; }