At 09:22 -0800 20/11/06, 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? You could also write the Perl script from the AS script as below. This avoids the inconvenience of dealing with unexpected quotation characters. I've written this so that it will work in Smile too, which still uses CR rather than LF as the line-ending. set _listfile to "/tmp/list.txt" set _scriptfile to "/tmp/script.pl" set _lf to ASCII character 10 ----- set _list to paragraphs of " one one and a half two three three and a half " ----- set _item to "one and a half" ----- PERL SCRIPT ----- set _script to paragraphs of " ($f, $item) = @ARGV; open F, $f or die $!; while (<F>) { chomp; next if /^$/; $i++; $hash{$_} = $i; }; print $hash{$item};" ----- ----- set _f to POSIX file _listfile open for access _f with write permission set eof _f to 0 repeat with p in _list write p & _lf to _f end repeat close access _f set _f to POSIX file _scriptfile set eof _f to 0 open for access _f with write permission repeat with p in _script write p & _lf to _f end repeat close access _f do shell script "perl " & Â quoted form of _scriptfile & space & Â quoted form of _listfile & space & Â quoted form of _item