perlquestion
perlguru22
How can you find the sum of an array using just shift and pop?
<code>
#! 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";
</code>
I tried using a for loop but I don't think that worked either.