Re: [MacPerl-Porters] 5.6.1b2 and AmphetaDesk...

[email protected] (Thomas Wegner) Wed, 5 Dec 2001 09:49:39 +0100
Newsgroups perl.macperl.porters
Message-ID <p04320400b8338a69990e@[149.225.70.139]>
At 0:58 Uhr -0500 05.12.2001, Morbus Iff wrote:
>Since XML::Parser was ported to the 5.6.1b2 MacPerl, I decided to try
>AmphetaDesk with it and see how things were going. Of non-shipped MacPerl
>Beta modules, I use only two: XML::Parser and XML::Simple. My XML::Simple
>installation was a cheat - I just dragged over my 5.004 copy from my
>previous MacPerl installation.
>
>Ignoring the below, AmphetaDesk ran perfectly in the
>beta, and I could notice some speed increases as well.
>Just a matter of getting a RuntimeBuilder working
>and I'll be perfectly happy with the beta release ;)...
>
>##########################################################################
>NOTE: I know I should be using File::Spec to create the path names below.
>When I wrote the faulty code, I didn't know it existed, so don't kill me.
>##########################################################################
>
>In the current MacPerl release:
>
>  #!/usr/bin/perl
>  use Cwd;
>  my $location = getcwd;
>  print $location;
>
>  Splooge:Applications (Mac OS 9):MacPerl Ÿ
>
>In the current MacPerl beta, the same code prints:
>
>  Splooge:Applications (Mac OS 9):MacPerl Beta Ÿ:
>
>Notice the delimiter at the end. In the current AmphetaDesk code, I add the
>delimiter to $location myself (I know, File::Spec, you scream. Shuddup,
>already!). Later on in the script, I -e on the $location and everything
>works fine.
>
>With no modifications in the beta, my -e will fail on $location. Due to my
>previous adding of delimiter to $location, I get something like:
>
>  Splooge:Applications (Mac OS 9):MacPerl Beta Ÿ::filename.txt
>
>And this causes the -e to fail within 5.6.1b2.
>
>When I run the same code within the OS X Terminal, I get:
>
>  /Users/morbus
>
>Which duplicates the current 5.004 MacPerl behavior. Which
>is correct? Is this a bug? Should I report it as a bug?
>
>--
>Morbus Iff ( i am your scary godmother )
>http://www.disobey.com/ && http://www.gamegrene.com/
>please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
>icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus


Morbus,

this is not a bug, it's a feature. You will see, that most modules and functions and operators dealing with file specifications now behave like this. MacPerl 5.6.1 standardizes on always ending in a colon for a directories. Although a trailing ':'  is not necessary for directories, it makes sense when it comes to distinguish files from directories literally, without consulting the filesystem (e.g., some of the File::Spec::Mac routines make use of this). Furthermore, a volume name (kind of directory) requires a trailing colon as you know, so it's better to always have a colon appended.

However, this does *not* mean, that you can't use, say -d "MacHD:Desktop Folder", where "Desktop Folder" is a directory. Let's say your current directory is "MacHD:", then -d "Desktop Folder", -d ":Desktop Folder" and -d ":Desktop Folder:" are all valid, although I would recommend the third variant.

To avoid problems between MacPerl versions, either use File::Spec or a substitution regex like $dir =~ s/:$//;

Regarding Unix, both /Users/morbus and /Users/morbus/ are valid, but the first seems to be the canonical form.


Best regards,

--Thomas

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com