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

[MacPerl] DoAppleScript & Perl dbm files



I can't get the desired result when calling this script from 
AppleScript, although it works fine when run from MacPerl 5.06 itself:

#!/usr/local/bin/perl

dbmopen(%my_array,"my_arrayfile",0644) || die "Ooops" ;
foreach $key (sort keys %my_array) {
$result .= $key." : ".$my_array{$key}."\n";}
dbmclose(%my_array);

print $result,"\n"; 
&MacPerl'Reply("$result\n");
&MacPerl'Quit(0);

When the AS script runs, it launches MacPerl, which immediately returns 
an empty string with a return on it. The foreach loop never gets done, 
because when it does run it should take at least 15 seconds to complete. 

If I change 

&MacPerl'Reply("$result\n");  

to 

MacPerl'Reply("this script is done"); 

it returns the string to my AppleScript script as expected. So I know I 
can pass values. 

I've had success with other Perl scripts which return a variable, like 
$result, but never when assigning values from a dbm file to a string. I 
am confused as to why. Any help? 

Oh, the AppleScript is:

set myScript to "myPath:myFilename"
tell application "MacPerl"
Do Script myScript mode batch
set x to the result
end tell
do something with x

Thanks,