in reply to Summing the elements of multiple arrays into a new array
You could just flatten out the loop you have:
my @foo = my @bar = qw(1 2 3 4); my @foobar; $foobar[$_] = $foo[$_] + $bar[$_] for 0 .. $#foo;
Now it will handle any two equally sized arrays and is fairly readable.
HTH,
Charles K. Clarkson
|
---|
In Section
Seekers of Perl Wisdom