Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

How does one compare the relationship between two file system paths in a portable way?

by ELISHEVA (Prior)
on Aug 17, 2009 at 22:47 UTC ( [id://789299]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #   Failed test 'comparePaths(/a/b, /a)'
    #   in Monks/Snippet.pm at line 132.
    ...
    #          got: '-2'
    #     expected: '-1'
    # Looks like you failed 4 tests of 36.
    
  2. or download this
    #   Failed test 'comparePaths(/, /a)'
    #   in Monks/Snippet.pm at line 108.
    ...
    #          got: '-2'
    #     expected: '-1'
    # Looks like you failed 4 tests of 36.
    
  3. or download this
        #replace
        my @aDirs = File::Spec->splitdir($sDirPart);
    ...
        my @aDirs = $sDirPart eq File::Spec->rootdir()
          ? ('') : File::Spec->splitdir($sDirPart);
    
  4. or download this
    use strict;
    use warnings;
    ...
    is(comparePaths('/a/b/', '/a/x'), -2, "comparePaths(/a/b/, /a/x)");
    is(comparePaths('/a/b/', '/a/x/'), -2, "comparePaths(/a/b/, /a/x/)");
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found