Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: regex alternation

by moritz (Cardinal)
on Sep 30, 2011 at 10:19 UTC ( #928736=note: print w/replies, xml ) Need Help??


in reply to regex alternation

You can try something along these lines to avoid invoking the regex engine:

my $prefix = "in directory '/directory/tmp"; my $prefix_len = length $prefix; my $test3 = qr<^$prefix(/\..*'|')$>; for my $line (@test_array) { if (substr($line, 0, $prefix_len) eq $prefix && $line =~ $test3) { print "MATCHED\n"; } else { print "NO MATCH\n"; } }

But you need to Benchmark it to find out if it's actually faster with your data.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928736]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2016-12-09 08:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (148 votes). Check out past polls.