For me this arose using Filter::Simple on arbitrary code.
The snippet uses tr/// backwards in a sense, the eval is required as tr's char sets are determined at compile time
TIMTOWTDI but it think this is nice, though perhaps not best.
Update: There's a bit of chicken-egg action here. Can't believe I didn't notice it for 6 months.$possibly_safe = "^!|~¦¡£\0"; $mystery_str = '$a !~ /qr^some|thing^'; $mystery_str =~ tr!/!!d; # make eval interpolation safe eval "(\$safe = \$possibly_safe) =~ tr/$mystery_str//d"; print $safe; # "¦¡£\0"
The old code:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding a safe char with tr///d
by BrowserUk (Patriarch) on Jan 29, 2003 at 00:51 UTC | |
by Aristotle (Chancellor) on Jan 31, 2003 at 04:21 UTC | |
by BrowserUk (Patriarch) on Jan 31, 2003 at 04:37 UTC |