http://www.perlmonks.org?node_id=590753


in reply to File::Basename is dog slow

I assume you're talking about this code (from parsefile):
if (@suffices) { $tail = ''; foreach $suffix (@suffices) { my $pat = ($igncase ? '(?i)' : '') . "($suffix)\$"; if ($basename =~ s/$pat//s) { $taint .= substr($suffix,0,0); $tail = $1 . $tail; } } }
It recompiles a regex for every suffix on every call to parsefile. Yuck! This module could use another function that saves a regex to do the suffix checking (in a closure or an object). Or something :-)