Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: split a path/filename

by dd-b (Monk)
on Dec 01, 2011 at 18:38 UTC ( [id://941140]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://941140]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found