perlguru22 has asked for the wisdom of the Perl Monks concerning the following question:
How can you find the sum of an array using just shift and pop?
I tried using a for loop but I don't think that worked either.#! usr/bin/perl @nums = (1,2,3,4); $s = shift@nums; \\ I know that gives $s 1 $p = pop@nums; \\ This gives $p 4 $sum += $_ for @nums; print "$sum";
Back to
Seekers of Perl Wisdom