/o can still be useful from time to time. Firstly, you occasionally expect that the interpolated variable may change but still want to use the original value (but this is rare). Secondly, the "recompile only if changed" logic requires checking whether the pattern has changed, which takes time:
perl -MBenchmark -w
($s, $t) = qw/ foo xfoox /;
timethese(-1, {
oful => q{ $t =~ /$s/o },
oless => q{ $t =~ /$s/ },
})
__END__
Benchmark: running oful, oless for at least 1 CPU seconds...
oful: 2 wallclock secs ( 1.08 usr + 0.00 sys = 1.08 CPU) @
+2427258.33/s (n=2621439)
oless: 2 wallclock secs ( 1.15 usr + 0.00 sys = 1.15 CPU) @
+1841144.35/s (n=2117316)
Hugo
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|