http://www.perlmonks.org?node_id=122393

djw has asked for the wisdom of the Perl Monks concerning the following question:

I am adding elements of multiple arrays together and creating a new array with the sum. I was curious to know if there was a perlish one-liner type way of doing this. Here is how I'd do it using a loop:
# using a loop @foo = qw(1 2 3 4); @bar = qw(1 2 3 4); for ($i = 0; $i < 4; $i++) { $foobar[$i] = $foo[$i] + $bar[$i]; } # @foobar is now (2 4 6 8).

I have no problem doing it that way, but I was just curious. One day I may need to do this to more than two 4 element arrays and I won't want to type all that =)

djw