in reply to split a path/filename

And I'm in the habit of using File::Spec. So now I've learned of two other approaches.

Replies are listed 'Best First'.
Re^2: split a path/filename
by ikegami (Patriarch) on Dec 01, 2011 at 20:52 UTC

    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;
      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". ;-)