in reply to Re:{3} Regex Grumblings (Variable Interpolation)
in thread Regex Grumblings (Variable Interpolation)
Don't you mean
/\Q$foo\E/ and print "$&\n"; s/\Q$foo\E/XYZ/;
Using -w would have helped you figure it out.
Update: oh right, deliberate tyops. Well, now that I've really thought about it... this is what is going on. The line
/\Q$fooE/ and print "$&\n";
given that $fooE is not defined is the same thing as
/\Q/ and print "$&\n";
which is the same thing as
// and print "$&\n";
Which is the same thing as finding the same thing as the last successful match. This also applies to the s expression, which is why your bar appears to be magically transmuting itself into XYZ.
That's not a bug, that's a feature.
|
|---|