in reply to Re^7: Shouldn't references be readonly? (updated)
in thread Shouldn't LITERAL references be readonly? (updated)
The undef $_++ vs $$_++ I think the former is working because what's happening is:
- An SVrv pointing to the SV* for undef is pushed on the arg stack
- When map calls the EXPR $_++ that reference is getting numified, incremented, and that new int value stuck back into the SV* on the arg stack
- Since it's a postincrement the map is returning the original value of $_ which is the ref to undef
- The call stack goes away and with it the SV* which had the numified address plus one.
In the second case you're explicitly dereferencing the SVrv to the constant undef and trying to increment that (which fails because undef is a singleton readonly SV*).
Edit: And again yes making explanation by way of the implementation, but I think that's because knowing (sort of) how this is implemented under the covers makes these particular corner cases' behaviors not (as) surprising.
The cake is a lie.
The cake is a lie.
The cake is a lie.
In Section
Seekers of Perl Wisdom