note
MarkM
<p>Interesting. It looks like you've found yet another piece of Perl that isn't implemented in the most optimal manner. :-)</p>
<p>Playing around, I found that on my system, the following tweak allows the 'single regexp match' to beat the 'split into a temporary list, and grab the last entry' approach by ~15%:</p>
<code>$f =~ /(?:.*\/)?(.+)/s; my $fn = $1;</code>
<p>I'm still surprised that Perl can match against '/' several times (split) faster than it can skip to the last '/' with a single rather simple match. It seems the Perl regular expression engine could still use a few optimizations. Until then, I suppose explicit optimization isn't that bad.</p>
<p>Cheers,<br>mark</p>
284844
285124