in reply to Extract main name of file
Also core module File::Spec and notably the splitpath function can be useful
($volume,$directories,$file) = File::Spec->splitpath( $path );
Then you need to manage the extension of the file with a regex or as you have done already.
L*
|
|---|