![]() |
|
Perl: the Markov chain saw | |
PerlMonks |
Re: How can I add all the numbers in an array with out doing a foreach loop?by smithfarm (Initiate) |
on Oct 20, 2013 at 08:19 UTC ( [id://1059000]=note: print w/replies, xml ) | Need Help?? |
Use the grep function:
Or, equivalently, use the map function: 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.
In Section
Seekers of Perl Wisdom
|
|