Hello. I am using tinyperl with the following script:
@lines=<STDIN>;
foreach (@lines) {
s/\\(.)/($1 eq '"' or $1 eq '\\') ? $1 : '\\' . $1/eg;
print;
}
I would like each backslash to be considered only with the following character, and remove the backslash only if the following character is a double quote or another backslash. (I know this purpose might be unsound to you, but never mind).
For example, I would like to translate abc\ndef\\ghi\"\\\n
to abc\ndef\ghi"\\n
. But this script seems to translate it to abcndef\ghi"\n
instead.
Could you help?