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

Re: Speed of Perl Regex Engine

by Jenda (Abbot)
on Nov 29, 2012 at 16:43 UTC ( #1006298=note: print w/replies, xml ) Need Help??

in reply to Speed of Perl Regex Engine

You said you build the regex and pass it to the program as a parameter ... how do you use it then?

my $regexp = @ARGV[1]; ... next if ($global =~ /$regexp/); ...
my $regexp = @ARGV[1]; ... next if ($global =~ /$regexp/o); ...
my $regexp = qr/@ARGV[1]/; ... next if ($global =~ $regexp); ...

The first version compiles the regexp each time you use it, the other two just once. For a longer regexp this may make a big difference.

Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^2: Speed of Perl Regex Engine
by runrig (Abbot) on Nov 29, 2012 at 19:30 UTC
    I believe in later versions of Perl (>= 5.6), this is no longer true. As long as $regexp doesn't change, /$regexp/ isn't compiled again, making "/o" (mostly) obsolete.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006298]
[1nickt]: think that might be a winner, stevieb
[1nickt]: My wife is doing a uni degree on line and using a 17" laptop with 1600 x 900 res. But she won;t let me upgrade her screen unless she still gets 17", full keybd, and dvd writer!

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-03-26 18:30 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (315 votes). Check out past polls.