Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^4: Transform ASCII into UniCode (escape_metas)by LanX (Saint) |
on Mar 23, 2021 at 18:18 UTC ( [id://11130228]=note: print w/replies, xml ) | Need Help?? |
> Why not test it directly, then? 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
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 (?)
updateI.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
In Section
Seekers of Perl Wisdom
|
|