#!/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;