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


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

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;