chen li schreef:

> 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

#!/usr/bin/perl
  use warnings ;
  use strict ;

  my @AoA =
  (
      [1,2,3,4,5],
      [1,2,3,4,5],
      [1,2,3,4,5],
      [1,2,3,4,5],
  ) ;

  my @sum ;

  for my $row (@AoA)
  {
      $sum[$_] += $row->[$_]
        for $[ .. $#$row ;
  }

  print "@sum\n" ;

__END__

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to