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