![]() |
|
more useful options | |
PerlMonks |
Can we make $& better?by TedYoung (Deacon) |
on Sep 06, 2007 at 18:05 UTC ( #637490=perlquestion: print w/replies, xml ) | Need Help?? |
TedYoung has asked for the wisdom of the Perl Monks concerning the following question: Anyone who does anything significant with regular expressions learns that the variables $&, $' and $` imposes significant performance penalty on all regular expression matches. I have personally witnessed just how significant the use of these variables can be on performance (KinoSearch & Large Documents). perlvar says under @- the following:
So my question is why can't these variables be implemented this way behind the scenes. If I could get access to the last variable successfully matched against, for instance, I could write a Tie interface for these variables very easy. I am guessing it has to do with keeping track of the last variable matched and handling cases where that variable is changed before reading $& (such as assignment or a s///). This question is really out of curiosity about the internals of the perl regexp engine. Thanks, Ted Young ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
Back to
Seekers of Perl Wisdom
|
|