http://www.perlmonks.org?node_id=1047826


in reply to Appending new column data to CSV file?

In the while loop, these 2 statements:
$sum += $col5; push @numbers, $col5;
$sum and @numbers need to be declared before the while loop that reads the file. Then after each file is read, statements:
while (my ($i, $num) = each @numbers) { push @{ $output[$i] }, $num/$sum; }
You would need to declare @output before the foreach loop begins.

Then after all the files have been read and the info collected, you could print it out like: print OUT join(",", @$_), "\n" for @output;