"be consistent" | |
PerlMonks |
Re: Re: Cross platform compatability Part 1: Shells and Filesby chipmunk (Parson) |
on Jan 21, 2001 at 22:36 UTC ( [id://53357]=note: print w/replies, xml ) | Need Help?? |
I'm curious to know what MacPerl does whether it converts file/path/ to file:path: or it actually needs colons.
MacPerl does not convert 'file/path/' to 'file:path:'; one must actually use colons in the paths. Even trickier, however, is the way of specifying relative paths, by prepending the directory separator. On a Mac, ':mammal:dog' means the file dog in the directory mammal in the current working directory, whereas on Unix '/mammal/dog' means the file dog in the directory mammal in the root directory. On the other hand, the path 'animal:mammal:dog' on a Mac means the file dog in the directory mammal in the root directory of the volume animal. On Unix 'animal/mammal/dog' means the file 'dog' in the directory 'mammal' in the directory 'animal' in the current working directory. Here's a script that demonstrates this behavior in MacPerl:
Getting cross-platform file paths is not an easy problem. That's why the File::Spec module was created. (Except that all the documentation for the module is in File::Spec::Unix. You'll have to read it locally.)
In Section
Meditations
|
|