At 20:11 +0900 12/9/07, Peter N Lewis wrote:
>At 19:01 -0500 8/12/07, Dan Neville wrote:
>>Does anyone know how to make a Mac OS alias in Perl? So, I wish to have
Perl create aliases in multiple directories rather than copy the original
file.
>
>There actually is no API call to create an alias file.
>
>You can do it in Perl as described at
>
><http://use.perl.org/~pudge/journal/10437>
>
>Alternatively, you can make a new alias via AppleScripting the Finder as:
>
>set thaAlias to "Harddisk:Users:peter:thefile.cpp" as alias
>
>tell application "Finder"
> set f to make new alias file at desktop to thaAlias
>end tell
If you're not into the O-O stuff involved with the AppleScript modules,
and you're not in a hurry, it's possible to invoke the osascript tool from
within perl using backticks. You can create a string of AppleScript
commands to pass to it with simple perl concatenations like ".=" or you
can use a << "here" do***ent with perl's here or with shell's here
depending on how you set the backticks.
Test your AppleScript code with Script Editor first.
Using Finder is pretty much required because Finder "owns" the
specification for an alias file. I have never seen a formal description of
that or, for that matter, an alias resource. They are based on the file-id
number which never repeats as files are created on a partition but there
is more to it because that doesn't always work. Aliases do survive a file
name change by the user and they use volume names so that Finder can
request a floppy by name if an old alias pops up. What can cause an alias
to fail is an editor that always writes the changed file to a newly
created copy and then changes the names around so the original becomes the
backup. The alias will point to the original while a symbolic link will
point to the new.
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.


|