Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by ikegami (Pope)
on Jun 27, 2010 at 20:32 UTC ( #846804=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Compiles each pattern once since m// realises
    # you're using the same pattern twice in a row.
    ...
          /$re/
       }
    }
    
  2. or download this
    # Compiles each pattern twice
    for (1..2) {
    ...
          /$re/
       }
    }
    
  3. or download this
    # Compiles each pattern once
    my @res = map qr/$_/, qw( foo bar );
    ...
          /$re/
       }
    }
    
  4. or download this
    # Doesn't recompile $re if it's a qr//.
    /$re/
    ...
    # Stringifies and recompiles $re if it's a qr//,
    # but it should be subject to the caching mentioned above.
    /x$re/
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2015-07-04 16:07 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 (60 votes), past polls