in reply to sum of integers in a column
#!/usr/bin/perl ##Assume the following array having data in the matrix form. @a=( qw(1 2 3), qw(1 2 3), qw(1 2 3) ); for (my $j=0;$j <= ($#{$a[0]}) ;$j++) { my $sum=0; print "=======\n"; for(my $i=0;$i<=$#a;$i++) { print "$i$j=$a$i$j \n"; $sum+=$a$i$j; } push @a, $sum; print "\n$sum\n"; } print "\naaaa===\n@a\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sum of integers in a column
by sbmp111 (Novice) on Oct 12, 2010 at 14:52 UTC |