MACSCRPT Archives

November 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Tue, 21 Nov 2006 11:36:08 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (44 lines)
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?

ATOM RSS1 RSS2