in reply to How can you make this script general?
You should notice that Perl arrays are autovivified, where if you use an index out of range, the array will be auto-expanded.
So what you need is: use an array to record the sum of columns. each time you read a line, and add the columns to the sum array.
my @sum; while (<FH>) { chomp; my @F = split /\t/; $sum[$_] += $F[$_] for 0..@F-1; }
|
|---|