in reply to Multi-Column Totals

Here's the suggestion I offered in the Chatterbox. It keeps an array of running totals:
#!/usr/bin/perl -w use strict; $\ = "\n"; my @total; foreach my $row ( 1 .. 10 ) { my @output; foreach my $column ( 1 .. 10 ) { push @output , $column; $total[$#output] += $column; } print join ',' , @output; } # print column totals here print 'total:'; print join ',' , @total;
which gives:
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9,10
total:
10,20,30,40,50,60,70,80,90,100