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;$_/$.};
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'