http://qs1969.pair.com?node_id=316003


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.


Dave

Replies are listed 'Best First'.
Re: Re: Naughty Regular Expressions and mod_perl
by Anonymous Monk on Dec 20, 2003 at 19:26 UTC

    Hello?

    In your rush to show how much you know about Regexes, you forgot what the original question was.

    And the question was "do I have to suffer for the effects of naughty regexes if somebody else in the same environment is using them?"

    The question WAS NOT "show me how smart you are with @+ and @-"

    Ask around. Everybody in the Monastery believes that Ovid knows a few things about regexes and he wasn't waiting for your self-promoting remarks to come out of the darkness.

      The original question did provide context, including the fact that there was legacy code involved using the match vars. Tips for changing that code without having to substantially change the logic (always a good thing with legacy code) are certainly appropriate.

      I think a disclaimer about authorship is also appropriate; I would call it modesty, not self-promotion.