Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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/

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://661317]
NodeReaper snacks on some Soylent Green

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2017-11-25 04:20 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (355 votes). Check out past polls.