Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: CPAN Module for mixing Unix/Windows path

by mandarin (Pilgrim)
on Jun 05, 2008 at 12:27 UTC ( #690411=note: print w/ replies, xml ) Need Help??


in reply to Re: CPAN Module for mixing Unix/Windows path
in thread CPAN Module for mixing Unix/Windows path

Maybe I misread your 'consistent', but for me

use File::Spec::Functions qw( catdir ); print catdir('/home/foo/abc', 'bar\baz');
gives
/home/foo/abc/bar\baz
which is not what I would have expected (i.e. either all forward or all backward slashes). This is perl 5.8.8. on linux


Comment on Re^2: CPAN Module for mixing Unix/Windows path
Select or Download Code
Re^3: CPAN Module for mixing Unix/Windows path
by ikegami (Pope) on Jun 05, 2008 at 14:09 UTC

    Your test is invalid. File::Spec will never produce 'bar\baz'* on your system. Reread the OP.

    Update: I thought it went without saying given the context, but:
    * — where '\' is a path separator.

      I surely must be missing something here. In what way my test is invalid? I just was curious what catdir would do, so I downloaded your code, stripped the lean_forward sub and added a print statement.
      And was surprised by the output, as it contained a backslash.
      File::Spec will never produce 'bar\baz' on your system
      Well, it does. Double-checked it.
      'bar\baz' would make a valid unix filename, so maybe File::Spec does not render the '\' as a path seperator?

        Either '\' is a path separator or it's not. You can't have it both ways.

        If '\' is not a path separator, then it cannot be replaced with '/' and your test did return consistent and expected results, contrary to what you said.

        If '\' is a path separator, then it couldn't have been produced by File::Spec on your system and your test is invalid since the OP said that path is produced by File::Spec.

        The only system where it's safe or valid to change 'bar\baz' to 'bar/baz' is a Win32 system.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2014-08-20 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (124 votes), past polls