Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Naughty Regular Expressions and mod_perl

by davido (Cardinal)
on Dec 20, 2003 at 06:31 UTC ( #316003=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://316003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-08-13 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?