--- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > > > I have an array of array look like this: > > > > @array_of_array=( > > > > [1,2,3,4,5], > > [1,2,3,4,5], > > [1,2,3,4,5], > > [1,2,3,4,5] > > ) > > > > How do I get the total values for each colume, > such as > > > > $column1=1+1+1+1; > > $column2=2+2+2+2; > > $column3=3+3+3+3; > > $ perl -le' > my @array_of_array = ( > [ 1, 2, 3, 4, 5 ], > [ 1, 2, 3, 4, 5 ], > [ 1, 2, 3, 4, 5 ], > [ 1, 2, 3, 4, 5 ], > ); > my @total; > for my $row ( @array_of_array ) { > for my $column ( 0 .. $#$row ) { > $total[ $column ] += $row->[ $column ]; > } > } > print "@total"; > ' > 4 8 12 16 20 > > > > John
Hi John, Thanks for the script but I am not familiar this code line $total[ $column ] += $row->[ $column ]; Can you or anyone else explain it a bit more? Li __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>