in reply to using pop and shift to find the sum of an array
The usual and most readable way is this:
use v5.14; my @nums = (1,2,3,4); say do{local($_,$.);$_+=pop(@nums)*!!++$. while@nums;$_/$.}; [download]