in reply to Naughty Regular Expressions and mod_perl

Modern Perl implementations (v5.6.1 and later, I think) provide the @+ and @- arrays that give information about the position of the last match in strings.

The RegExps, Prematch and Postmatch without efficiency penalty discussion thread provides a solution for using @+ and @- along with either substr or unpack as a means of accomplishing the same thing as $`, $', and $&, but without the performance penalties. I happen to like that node, but I'm biased because I wrote it a few months back. I hope you find it helpful.

You will also find information on using these special arrays instead of the $`, $', and $& special variables in perlvar.

Good luck! There is a good workaround.