in reply to Faster search and replace?

You might consider sorting the keys too. The minor slowdown may someday pay off in the regex optimizer. Of course I took the Regex book to work Monday so I don't have it here. It said something about refactoring similar words and order dependencies in alternations...

Other than s///go as mentioned already, I don't see anything else you can do with this. I'd have to throw Benchmark at alternatives since this is pretty sexy code =)

--
$you = new YOU;
honk() if $you->love(perl)

Replies are listed 'Best First'.
RE: RE: Faster search and replace?
by snax (Hermit) on Nov 09, 2000 at 17:25 UTC
    *blush* I've always been fond of this little piece of code :)

    Anyway, here's the lowdown: for situations where I want to replace text tags in form templates, this is a great hack. For the task that made me wonder if it might be inefficient, it proved to be the Wrong Tool. Doing the translation from Mac euro-characters to their Windows code page equivalents is definitely a

    tr///
    job. Crude benchmarks suggest an enormous difference: less than a second for a translation that used to take almost a minute.

    Your humble supplicant is most pleased with the wisdom imparted by the Monks :)