Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: UNC vs. standard Perl functions

by brian_d_foy (Abbot)
on Mar 16, 2005 at 18:40 UTC ( [id://440081]=note: print w/replies, xml ) Need Help??


in reply to UNC vs. standard Perl functions

It's not a bug in Perl, and it's not a bug in File::Spec::Functions: it's documented (and intended) behavior.

At the beginning of File::Spec, it looks at the value of $^O to see which operating system it's on, then selects an appropriate subclass. On Windows, that's File::Spec::Win32, and in that module it defines the directory separator.

You want it to pick something else. You could add a subclass for UNC so the module handles the root directory and other things correctly, or you can make File::Spec think that it's on another system. I sometimes need to do this to work with paths from other systems without turning them into UNIX paths.

#!/usr/bin/perl BEGIN { local $^O = 'MSWin32'; # or Unix MacOS VMS, and so on require File::Spec::Functions; File::Spec::Functions->import; } my $path = catfile( 'top', 'middle', 'bottom' ); print $path, "\n";

I run this on FreeBSD and get "top\middle\bottom".

--
brian d foy <bdfoy@cpan.org>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found