Hello Paul,
Well, I think you can use any Perl script from within AppleScript
script via do shell script, using the "perl -e '...'" format. In
this case, you would do (for example):
set my_list to {"a", "i", "u", "e", "o"}
set oldDelim to text item delimiters
set text item delimiters to ","
set my_str to my_list as text
set text item delimiters to oldDelim
return_indice(my_str, "o") --> 5
on return_indice(str, your_word)
set perl_scpt to "$str = shift;
$word = shift; $i = 1;
map {$dummy{$_} = $i; $i++} split (/, */, $str);
print $dummy{$word} if exists $dummy{$word}"
set res to (do shell script "perl -e '" & perl_scpt & "'" & space &
quoted form of str & space & quoted form of your_word)
if res is missing value then
return 0
else
return res as number
end if
end return_indice
I hope this helps.
Best regards,
Nobumi Iyanaga
Tokyo,
Japan
On Nov 21, 2006, at 2:22 AM, Paul Berkowitz wrote:
>
> Thanks, Nobumi. Is this convertible to a single-line perl -e
> Terminal script
> which could be quoted and run as a 'do shell script', or must it be
> run from
> a file?
|