Perl:Sum an Array

From Progzoo
Jump to: navigation, search

You can add the numbers in the array [6,7,29] using a loop.

[Font] [Default] [Show] [Resize] [History] [Profile]

Alternately using the List::Util module:

use List::Util qw(sum);
my @a = (6,7,29);
print sum(0, @a);