<?xml version="1.0" encoding="windows-1252"?>
<node id="1006298" title="Re: Speed of Perl Regex Engine" created="2012-11-29 11:43:13" updated="2012-11-29 11:43:13">
<type id="11">
note</type>
<author id="105128">
Jenda</author>
<data>
<field name="doctext">
&lt;p&gt;You said you build the regex and pass it to the program as a parameter ... how do you use it then?&lt;/p&gt;

&lt;code&gt;
 my $regexp = @ARGV[1];
 ...
 next if ($global =~ /$regexp/);
 ...
&lt;/code&gt;

&lt;code&gt;
 my $regexp = @ARGV[1];
 ...
 next if ($global =~ /$regexp/o);
 ...
&lt;/code&gt;

&lt;code&gt;
 my $regexp = qr/@ARGV[1]/;
 ...
 next if ($global =~ $regexp);
 ...
&lt;/code&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-105128"&gt;
&lt;p&gt;Jenda&lt;br&gt;
&lt;b&gt;Enoch was right!&lt;/b&gt;&lt;br/&gt;
Enjoy the last years of Rome.
&lt;/p&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1006062</field>
<field name="parent_node">
1006062</field>
</data>
</node>
