You want to use regular expressions in perl to turn the literal
'\n' two character sequences into the actual tab and newline characters.
The trivial solution doesn’t work if you also want to allow the use of
'\\' to escape the “escape” sequence (e.g. so that
'\\node' expands to
'\\\n' does expand to a blackslash followed by a newline).
What you actually need, is something like
s/\\(.)/\\$1]/g; s/\\n]/\n/g; s/\\t]/\t/g; s/\\(.)]/$1/g;
Small discussion: this first substitution encapsulates every escape sequence
'\X]', so that the escaped
'X' can not interfere with the rest of the string. Then you can evaluate all the escapes you want, e.g. turn
'\n]' into a newline. Finally all remaining
'\X]' are expanded back to