in reply to Help with code for adding two arrays.

Your use of push is ...incorrect. See the docs for push() and you'll see that it requires more than one argument.

As for a recommendation on how to add the elements of two arrays, I would do it with List::MoreUtils, using the pairwise() subroutine. Here's from the POD:

pairwise BLOCK ARRAY1 ARRAY2
Evaluates BLOCK for each pair of elements in ARRAY1 and ARRAY2 and returns a new list consisting of BLOCK's return values. The two elements are set to $a and $b. Note that those two are aliases to the original value so changing them will modify the input arrays.

@a = (1 .. 5); @b = (11 .. 15); @x = pairwise { $a + $b } @a, @b; # returns 12, 14, 16, 18, 20

That's really the right tool for the job, and will lead to clearer code.


Dave