in reply to Re: split a path/filename
in thread split a path/filename

File::Spec is hard to use. I'm not even sure if the following is correct.

use File::Spec::Functions qw( catpath curdir splitpath ); my ($volume, $directories, $basename) = splitpath($qfn); $directories = curdir() if !length($directories); my $dirname = catpath($value, $directories, ''); say $dirname; say $basename;

Path::Class is a wrapper around it.

use Path::Class qw( file ); my $file = file($qfn); my $basename = $file->basename(); my $dirname = $file->parent(); say $dirname; say $basename;

Replies are listed 'Best First'.
Re^3: split a path/filename
by afoken (Chancellor) on Dec 02, 2011 at 09:54 UTC
    File::Spec is hard to use.

    Even worse, it is broken.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)