in reply to Re^4: Regex stored in a scalar
in thread Regex stored in a scalar

Agreed, but my only point was that, under Unix, if you enter "foo\n" at STDIN or at the command line, the backslash is lost and you get "foon" into your variable. So I needed to put two backslashes, meaning that I then needed to change from the string "\\n" to the newline character "\n" to get the replacement string "foo\n" I was looking for. There might be a better way, but at least I was showing that this was possible.

So, in effect, we are saying almost the same thing, I believe.

Escaping and quoting rules are not exactly identical in Perl and in Unix (and also not under Windows), so it can get a bit contrived (and not portable) exactly to get what you want.