Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: regex alternation

by moritz (Cardinal)
on Sep 30, 2011 at 10:19 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://928736]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-25 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found