in reply to Re: Can anyone help me to improve this code, please?
in thread Can anyone help me to improve this code, please?

I would quite likely use a hash instead of a joined OR pattern.

my %ext; @ext{@ext} = (1) x @ext;
and then instead of
return unless m/$re/
I'd put
return unless /(\.[^.]+$)/ and $ext{$1};

ihb