Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: catfile/catdir collapses two leading slashes //

by haoess (Curate)
on Sep 17, 2008 at 07:16 UTC ( #711897=note: print w/ replies, xml ) Need Help??


in reply to catfile/catdir collapses two leading slashes //

The name of a directory is not the same as its pathname, so why don't you use splitpath and catpath?

-- Frank


Comment on Re: catfile/catdir collapses two leading slashes //
Select or Download Code
Replies are listed 'Best First'.
Re^2: catfile/catdir collapses two leading slashes //
by repellent (Priest) on Sep 17, 2008 at 07:37 UTC
    Sure. But let's not stray off-topic :)
    use File::Spec::Functions qw(catdir catpath splitdir splitpath); my ($volume, $directories, $file) = splitpath '//special/semantic//pat +h/definition'; my @dir = splitdir $directories; my $dir1 = catdir @dir; # '/special/semantic/path' my $dir2 = join '/', @dir; # '//special/semantic//path/' my $path1 = catpath $volume, $dir1, $file; # '/special/semantic/path/d +efinition' my $path2 = catpath $volume, $dir2, $file; # '//special/semantic//path +/definition'

      The name of a directory is not the same as its pathname

    There's always confusion with file nomenclature. See File system nomenclature. Death to path!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-30 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls