[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Applescript and MacPerl



>I'm having trouble getting MacPerl variables into my applescripts.  I've
>never worked with this aspect of MacPerl before, so perhaps I'm just being
>dopey.
>[...]

The problem is the way you're quoting the here-document.  The problem is 
this line:

>&MacPerl'DoAppleScript(<<'END_SCRIPT');

Since you put single quotes around END_SCRIPT, it acts as if the body 
your AppleScript (the here-document) was in single quotes.  You could put 
double quotes around END_SCRIPT to get variable substitution, but then 
you'll need to be careful to quote the double quotes in the AppleScript.  
The following worked for me:

#!/usr/local/bin/perl

$x = "Text text";

&MacPerl'DoAppleScript(<<"END_SCRIPT");
tell application "MacPerl"
        make new Window
        copy \"$x\" & \"Inserting text the hard way.\" to character 1 of front 
Window
end tell
END_SCRIPT