Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Optimization for readability and speed (code)

by jeroenes (Priest)
on May 01, 2001 at 10:30 UTC ( #76888=note: print w/ replies, xml ) Need Help??


in reply to Optimization for readability and speed (code)

To speed up the regex:

1. Loose the grouping where you can. Do you really need to check the two-caps, of could you just say \L\w{2}?

2. Use the 'o' modifier, as you don't use variables in your regex (see perlop).

Hope this helps,

Jeroen
"We are not alone"(FZ)


Comment on Re: Optimization for readability and speed (code)
Re: Re: Optimization for readability and speed (code)
by MeowChow (Vicar) on May 01, 2001 at 10:36 UTC
    Perl automatically does the second optimization for you - it recompiles a regex only if it contains interpolated variables.
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2015-07-07 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls