in reply to Re^3: Changing quoted strings spanning more than one line (modifying constants)
in thread Changing quoted strings spanning more than one line

That's cute, but doesn't help explaining why $1 =~ tr/\n// doesn't attempt to modify $1, which is read-only

I know. Someone already explained that tr/\n// doesn't modify the variable on which acts because it wasn't asked to.

But it seems like map's $_ isn't being reset each time through the loop.

Apparently, Perl expands 0..4 into the 5 item list only once, possibly as an optimisation since 0..4 is constant. However, it doesn't set the read-only flag on the members of the expanded list. The map I constructed modifies this list that should be constant, but isn't.

Change 0..4 to 0,1,2,3,4 and you'll get a read-only violation.
Change ++$_ to 1+$_ and you won't modify the list.