In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Charlie Garrison) wrote:

> I am using Mac::Glue to get alias style strings from a FileMaker database. I
> need to convert the string into a posix style path for manipulation in perl.

I think your terminology is wrong.  An alias is not a string at all, but 
binary data.  I think what you want is to convert an HFS-style (or Mac 
OS-style) path to a Unix-style (or Mac OS X-style) path.


> I'm trying to do the equivalent of the following AppleScript:
> 
>     set file path to "HD:Users:charlie:test file"
>     set file str to (POSIX path of file path) as string
>     -- returns "/Users/charlie/test file"

This would be the equivalent:

   use Mac::Glue ':glue';

   my $app = new Mac::Glue 'System Events';
   my $file_path = 'Bourque:Users:pudge:Desktop:server';
   my $file_obj  = $app->obj(file => $file_path);

   print $file_obj->prop('POSIX path')->get;

   # prints '/Users/pudge/Desktop/server'


What's going on: you need to define what the path is, you create an object 
of class "file".  Then you get the "POSX path" property of the file object.

One of the many reasons to hate AppleScript.  :)  Figuring out what the heck 
is actually going on is not easy.  I think in the AppleScript version, it is 
automatically turning file_path into a file object for you.  Neat, but 
confusing.

Normally, Mac::Glue should automatically convert the paths for you, *if* it 
knows the path is indeed a path.  If it is just a raw string in a database, 
then yeah, it can't know, and it just returns the string unchanged.

Hope that helps,

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to