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


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

If you don't like a for loop, maybe a while would be acceptable?
my @arry = (1..10); my $sum = 0; $sum += pop @arry while @arry; print $sum,$/;

Originally posted as a Categorized Answer.

  • Comment on Re: How can I add all the numbers in an array with out doing a foreach loop?
  • Download Code