in reply to Escaping multiple escape chars
In single quote string literals, "\\" is interpreted as "\", "\'" is interpreted as "'", and everything else is left as is.
$txt = ' __\\U//__ '; print("$txt\n"); # Prints __\U//__ $txt = ' __\\\\U//__ '; print("$txt\n"); # Prints __\\U//__ $txt =~s/\\/\\\\/g; print("$txt\n"); # Prints __\\\\U//__
That only applies to string literals. If you had been reading from a file, your code would have worked:
$txt = <DATA>; print("$txt\n"); # Prints __\\U//__ $txt =~s/\\/\\\\/g; print("$txt\n"); # Prints __\\\\U//__ __DATA__ __\\U//__
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Escaping multiple escape chars
by JamesNC (Chaplain) on Dec 10, 2005 at 00:48 UTC | |
by ikegami (Patriarch) on Dec 10, 2005 at 06:11 UTC | |
by JamesNC (Chaplain) on Dec 10, 2005 at 06:56 UTC | |
by ikegami (Patriarch) on Dec 10, 2005 at 14:22 UTC | |
by JamesNC (Chaplain) on Dec 10, 2005 at 16:29 UTC | |
| |
by ikegami (Patriarch) on Dec 10, 2005 at 06:14 UTC | |
Re^2: Escaping multiple escape chars
by JamesNC (Chaplain) on Dec 09, 2005 at 21:03 UTC |