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


in reply to How can I add all the numbers in an array with out doing a foreach loop?

Use the grep function:
my $sum; grep { $sum += $_ } @arrayToSum;
Or, equivalently, use the map function:
my $sum; map { $sum += $_ } @arrayToSum;
Both grep and map apply the code in the code block to each element of @arrayToSum. The _result_ of the grep/map function is not interesting to us in this case, so we ignore it.