http://qs1969.pair.com?node_id=946977


in reply to Re^16: ref to read-only alias ... why? (notabug)
in thread ref to read-only alias ... why?

clearly, there are two different mechanisms: the first does not do aliasing, whereas the second does.

How can you claim that for(1..3) doesn't alias when you can clearly see ++$_; having an effect on what it returns?

In both for(1..3) and for(1), $_ is aliased to each value returned by the expression in the parens.

I'm sorry, but you're dead wrong here:

First, your example does not demonstrate a lack of aliasing. It just shows that $_ isn't aliased to $a. That's to be expected, because 1..$a doesn't return $a anymore than 0+$a does.

Second, you pulled a switcheroo. I said for(1..3) aliases (and proved that it does), but your code uses for(1..$a). for(1..$a) is implemented differently; it's a counting loop and not a foreach loop. It still aliases, though.

Is there any proof of that intention? Best in perldoc?

There was code written to specifically perform this effect. By definition, the effect must be intentional.