Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: line by line match on an array of strings

by holli (Monsignor)
on Jan 09, 2008 at 11:29 UTC ( #661317=note: print w/ replies, xml ) Need Help??


in reply to line by line match on an array of strings

You could try to feed your strings into Regexp::Assemble. That way you get a single regex you can use to test your lines against, which would probably speed things up. OTOH, you cannot tell wich of your original search strings actually matched the line, if that is important for you. If it is, then you would have to do your explicit tests after the regex matched. Depending on the blank/hit ratio it may still be faster.

Update: as per bibliophile's comment below.



holli, /regexed monk/


Comment on Re: line by line match on an array of strings
Download Code
Re^2: line by line match on an array of strings
by bibliophile (Parson) on Jan 09, 2008 at 14:52 UTC
    Interesting. I'd never heard of Regexp::Assemble...
    From the doc:
    It is also possible to track the original patterns,
    so that you can determine which, among the source patterns
    that form the assembled pattern, was the one that caused
    the match to occur.
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-07-30 01:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls