how to pass Applescript's List to Perl script

Hi,

Could anybody help me on the following task.

I have a list [of numbers] in the applescript. I want to pass this list to a Perl script.

In the perl script, this numbers are added and total is returned back to applescipt.

Please help me on this to understand how to pass arguments from Applescript to Perl script.

Thanks,
Gopal

hello,

is perl an absolute necessity?


set myList to {1, 1.5, -4.732, 0.232}

set |sum| to 0
repeat with i in myList
	set |sum| to |sum| + i
end repeat

or…

set strList to "(1, 1.5, -4.732, 0.232)"
(do shell script " perl -e 'foreach $i " & strList & " {$_sum+=$i;}; print \"$_sum\\n\"'") as number

Hi Gopal,

This article is about Python<->AppleScript communication, but it applies to other scripting languages as well.

Generally you will have AppleScript to call the Perl script with a string argument (via do shell script), which is then parsed by the Perl script. The Perl script finally needs to print its result to the command line, so that AppleScript can get it.

Good luck!