If you never change the expression (the repl_ref hash) you can start by adding the o modifier to the regexp:
s/($repl_str)/$$repl_ref{$1}/go;That's the easiest and you might want to stop there if you're happy with the result.
If you want to speed it up more then you will have to work on the left part of the pattern. Is there any way you can match the repl_str stuff without a huge |? A character class maybe if you are looking for characters outside of the 0-127 range, or maybe an escape character and then an odd character? A mixture of the two? It depends on your data.
In reply to Re: Faster search and replace?
by mirod
in thread Faster search and replace?
by snax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |