in reply to Reaped: Re^3: Regex to extract last 3 components of filename
in thread Regex to extract last 3 components of filename

Lift it out and adapt it to your own code.

File::Spec is a core module. "Copy and paste some code out of a CPAN module" is a last resort at best.

Also be aware of the many goodies in Regexp::Common.

Regexp::Common does not handle filename manipulations.

  • Comment on Re^4: Regex to extract last 3 components of filename