Problems? Is your data what you think it is? | |
PerlMonks |
(Ovid - regexes as hash keys)Re: Mass Text Replacementby Ovid (Cardinal) |
on Apr 25, 2001 at 04:41 UTC ( [id://75333]=note: print w/replies, xml ) | Need Help?? |
I'm not sure I like the following solution, but how about turning your hash keys into regular expressions?
The above seems to work, but if you have 5000+ keys, that's going to take a huge amount of time to code and run about as fast as a one-legged dog. There's also the problem that it's easy to write inefficient regexes. The other idea that comes to mind is using the String::Approx module to try to match the keys to text. The problem with that is that it will be slower and more error prone :( tedv wrote: Of course, we link the initial This but not the this starting line 2.Why "of course"? Can you explicitly state a rule? Are you only trying to match the first occurrence of each string? If so, take off the /g on the substitution and it will work much faster.
Cheers, Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In Section
Seekers of Perl Wisdom
|
|