use Config;
my $pathsep = ":";
if ($Config{osname} =~ /darwin/i) {$pathsep = "/"; }
Be aware that this is not the only pathing gotcha converting MacPerl
scripts to UNIX perl (like MacOS X). The others I'm aware of (and can
think of right now) are:
- Modules which return paths (File::Basename, FindBin, etc.) return
trailing path separators for directories ("volume:folder:" instead of
"volume:folder") under MacPerl 5.6.1. This is different than UNIX perls
("/Volume/Folder") which always leave off the trailing path separator
(as did MacPerl 5.2.0). This is documented in the MacPerl changes docs.
- Sloppy concatenation of paths by UNIX folks tend to result in bad
paths on Mac. For example "/Volume/Folder1/" . "/Folder2" points to
"/Volume/Folder1/Folder2" on UNIX perl (the extra "//" is ignored). On
Mac "Volume:Folder1:" . ":Folder2" yields "Volume:Folder1::Folder2"
which actually points to "Volume:Folder2" because the "::" is the up-dir
spec on Mac (equivalent to "/../" on UNIX).
We wrote routines to handle these cases ourselves before we discovered
File::Spec, which does most of the dirty work for you.
Alex
--
Alex Harper [EMAIL PROTECTED]
Configuration Manager [EMAIL PROTECTED]
"Use whatever you think of first" -- Larry Wall
> -----Original Message-----
> From: Bill Becker [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 17, 2002 12:39 PM
> Cc: [EMAIL PROTECTED]
> Subject: Re: [MacPerl] MacOSX directory syntax
>
>
> What would be the best way to determine this programmatically ???
>
> Bruce Van Allen wrote:
> >
> > At 12:08 PM -0500 4/17/02, Tom Carr wrote:
> > >I wrote a simple perl script on macOS9.2 and want to move
> to an OSX box.
> > >When I run it on the OSX box, my path syntax is not
> working. Is the path
> > >syntax for OSX different than OS9?
> > >
> > >my $files_to_move = ':In'; #top level folder for search
> > >
> > >In this line, ":In" does not resolve. The "In" directory
> is in the same
> > >directory as the perl script.
> >
> > In OS X, Perl is uses the UNIX path separator, '/', instead
> of Mac's ':'.
> >
> > Also, paths are UNIX-style. If you use BBEdit, open the script or
> > file in question, and get the path from the toolbar button. That'll
> > give you an example to follow.
> >
>
>