in reply to Mass Text Replacement
For example, if I had the key "abc", I should translate ABC AB'C and A,B'C but not A B C.I dunna quite understand this bit. Your sample keys are things like "lines_of_text". Are you saying that you want to match "lines,of'text" but not "lines of text"?
The thing that springs to mind is two-parts. First, build a hash keyed like you have it above, with the proper substitution. At the same time, build a regular expression that encompasses all of your possible keys (yes, with lots of |'s). If you clarify what you're trying to match with a good example, it can probably be simplified greatly.
Use parenthesis with the substituion operator and a /e switch. Like:
So this would match variations of "foo", "bar", etc... but look them up in %table by the original (without the non-word character) names.s/(f\W*o\W*o|b\W*a\W*r|b\W*a\W*z|b\W*a\W*t) /($a=$1)=~s/\W+//g,$table{$a}/xe
If speed is a problem, consider using eval instead of a regular expression with alternations.
|
|---|