Just to have the one-line loop on here, since your real complaint is to get it all on one line:
(Note that you'd have to declare $sum someplace before the loop yet.)
@a = (1..10); $sum += $_ for @a;
In reply to Re: How can I add all the numbers in an array with out doing a foreach loop?
by DStaal
in thread How can I add all the numbers in an array with out doing a foreach loop?
by draco_iii
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |