http://www.perlmonks.org?node_id=1008864


in reply to Re^5: $1 not "freezing" in an addition
in thread $1 not "freezing" in an addition

I can count as high as 7...

sub r { $_[0] } # no-op? sub rr :lvalue { $_[0] } # no-op? $_ = 1; print ($_) + $_++; $_ = 1; print r($_) + $_++; $_ = 1; print $_ + $_++; $_ = 1; print $_ + ++$_; $_ = 1; print r(++$_) + r(++$_); $_ = 1; print ++$_ + ++$_; $_ = 1; print rr(++$_) + rr(++$_)++;

(Requires Perl 5.16, though you can get up to 6 in Perl 5.10 and above.)

Update: 0..10

use v5.16; no v5.17; no strict 'subs'; sub r { $_[0] } # no-op? sub rr :lvalue { $_[0] } # no-op? $_ = 1; say ( $ ++ _ ) + $_++; $_ = 1; say ($_) + $_++; $_ = 1; say r($_) + $_++; $_ = 1; say $_ + $_++; $_ = 1; say $_ + ++$_; $_ = 1; say r(++$_) + r(++$_); $_ = 1; say ++$_ + ++$_; $_ = 1; say rr(++$_) + rr(++$_)++; $_ = 1; say ++rr(++$_) + rr(++$_); $_ = 1; say ++rr(++$_) + rr(++$_)++; $_ = 1; say ++rr(++$_) + ++rr(r(rr(++$_)++));
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'