You can use shift operator in this case..
shift operator takes an array, removes an element from the start and updates the existing array
If your array becomes empty, it returns undef, which you can handle
sub average { $sum = shift @_; while (defined($num = shift @_)) { $sum += $num; } }
In reply to Re^3: Help with arrays
by Rohit Jain
in thread Help with arrays
by perlguru22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |