Interesting. It looks like you've found yet another piece of Perl that isn't implemented in the most optimal manner. :-)
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%:
$f =~ /(?:.*\/)?(.+)/s; my $fn = $1;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.
Cheers,
mark
In reply to Re: Re: file name parsing to get the original file name
by MarkM
in thread file name parsing to get the original file name
by tja_ariani
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |