At 11:49 Uhr -0700 17.04.2002, David Iberri wrote:
>Bill Becker wrote:
>
>> What would be the best way to determine this programmatically ???
>
>The File::Spec module should lead you in the right direction.
>
>$pathsep = File::Spec->catdir('');
>
>yields ":" for $pathsep on my Mac (running OS 8.6), and "/" on my Linux
>machine.
>
>Cheers,
>David Iberri

Noooooooo! Don't abuse File::Spec.

For me, running MacPerl 5.6.1, the following example script

    use File::Spec;

    $pathsep = File::Spec->catdir('');
    print "pathsep = $pathsep \n";

yields:

    pathsep = MacintoshHD:

which is a volume name, i.e. an absolute path.

Why? With MacPerl 5.6.1, catdir() has been changed to return relative paths by 
default, unless the first argument is an empty string (see File::Spec::Mac version 1.3 
for details). Although your statement was true with earlier versions of 
File::Spec::Mac (and MacPerl 5.2.0r4), it was true only by accident. catdir() was 
never designed to give you the path separator, not on Mac OS, not on Unix, not on VMS 
et al. In your example, the resulting ':' on Mac OS was meant to be the current 
directory, and the resulting '/' on Unix was/is meant to be the root directory.

Please don't do that at home, boys and girls.


Best regards,

--Thomas

 







Reply via email to