Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Regexp optimization - /o option better than precompiled regexp?

by jwkrahn (Monsignor)
on Jun 27, 2010 at 15:00 UTC ( #846782=note: print w/ replies, xml ) Need Help??


in reply to Regexp optimization - /o option better than precompiled regexp?

it seems that option /o offers better performance that precompiled regexp.

A "precompiled regexp" is one that has no variables and is therefore compiled at compile-time, for example m/999986/ or m/^abc.*def/.    Any regexp that contains a variable has to be compiled at run-time.    The /o option means that the regexp is interpolated and compiled only once for the complete life of the program.    Any other regexp that requires variable interpolation has to be interpolated and compiled each time that regexp is used.    The qr// operator allows you to interpolate and compile a regexp once, at run-time, for example from user input.


Comment on Re: Regexp optimization - /o option better than precompiled regexp?
Select or Download Code
Re^2: Regexp optimization - /o option better than precompiled regexp?
by Anonymous Monk on Jun 28, 2010 at 05:00 UTC

    "The /o option means that the regexp is interpolated and compiled only once for the complete life of the program."

    But why then is main::CORE:regcomp still being called on every iteration, just as in the cases without /o?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2014-09-16 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (156 votes), past polls