I wanted to have a generic method for escaping selected metas while keeping others as is.
> what did I do wrong?
Took me a moment to understand (well guess) what's happening
Take case #2:
a\\b is internally the 3 char string a\b , so this escape b is untouched.
but you do a string interpolation for
eval "\$string =~ tr/$s/$r/r"
so whats happening is
DB<57> say "a\\b" =~ tr/a\b/xyz/r # expected 'xyz' x\b DB<58>
Actually I'm not sure what tr's interpretation of \b is here
Question is if your expectation was right, because the literal code gives my result (?)
C:\tmp\t_wperl>perl -E"say 'a\\b' =~ tr/a\b/xyz/r # expected 'xyz'" x\b C:\tmp\t_wperl>
I.o.W.
Your expectation is to have a 1-to-1 mapping of characters.
My expectation was to emulate tr like implemented and to catch injections.
It's a question of definition.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re^4: Transform ASCII into UniCode (escape_metas)
by LanX
in thread Transform ASCII into UniCode
by Perlian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |