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

Started to reply with a similar Path::Tiny invocation then read what you'd linked so . . . foo. Instead, File::Spec(::Functions):

$ perl -MFile::Spec::Functions=splitdir -E '@p = splitdir( "/x/y/z/a/b +/c/d/e.f" );say join( qq{\n}, @p[-3,-2,-1] )' c d e.f

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.