19 ms·
perl -pe'BEGIN { $x = quotemeta(shift) } s/$x//g;' should do what you want. `quotemeta' is the function that does the escaping for your properly. I was hopin
by shabble 16y ago
perl -pe'BEGIN { $x = quotemeta(shift) } s/$x//g;'
should do what you want. `quotemeta' is the function that does the escaping for your properly.
I was hoping to be able to use tr///, since it seems like it was built for this, but it creates its conversion tables at compile time, so there's no chance to interpolate the argument without some nasty nasty eval'ing.
- nevinera 16y agoYeah, tr was my instinct as well.. Thanks for quotemeta, it helps with something I'm working on right now!