⭐ in reply to How can I add all the numbers in an array with out doing a foreach loop?
In functional style, using reduce from List::Util:
@a = (1..10); use List::Util qw(reduce); $sum = reduce { $a + $b } @a;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How can I add all the numbers in an array with out doing a foreach loop?
by ysth (Canon) on Nov 04, 2003 at 09:13 UTC |