Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Alternation vs. looping for multiple searches.

by aquarium (Curate)
on Nov 21, 2010 at 22:15 UTC ( #872820=note: print w/ replies, xml ) Need Help??


in reply to Alternation vs. looping for multiple searches.

there's always another way...you could construct and then eval code that tests the regexes one by one in sequence, shortcircuiting on first match found. you'd usually arrange to have the most common case first and least common case last, so that it short circuits at earliest opportunity.

/$regex1/ or /$regex2/ or /$regex3/......etc
the hardest line to type correctly is: stty erase ^H


Comment on Re: Alternation vs. looping for multiple searches.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2014-12-22 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (116 votes), past polls