Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by jwkrahn (Abbot)
on Jun 27, 2010 at 15:00 UTC ( [id://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.

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://846782]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found