$ perl -Mstrict -Mwarnings -E ' my @x = (0,1,3,2); my @y = map { state $z = 0; $z += $_ } @x; say "@y"; ' 0 1 4 6