Re: Do Perl Script?
Re: Do Perl Script?
- Subject: Re: Do Perl Script?
- From: Christopher Nebel <email@hidden>
- Date: Fri, 6 Jun 2003 14:32:13 -0700
On Friday, June 6, 2003, at 12:48 PM, John Delacour wrote:
At 9:38 am -0600 6/6/03, Gnarlodious wrote:
Can someone post a "Do shell script (perl)) to get my jumpstarted?
Chris Nebel's perl -e example is fine for the occasional quick script,
but you will soon hit insoluble problems. It's best to work with
files.
I don't know about "insoluble." Annoying, sure. In fact, past a
certain script size, it's probably more trouble than it's worth to try
to write the Perl script inside your AppleScript -- you should consider
keeping the Perl script in a separate file and packaging the two
together. All that double-backslashing gets pretty old after a while.
I'm not sure if JD intended his example to demonstrate one of these
"insoluble" problems or not, but it works quite easily with perl -e:
set perl_script to "
$string = hello;
$string =~ s/e/u/ ;
$string =~ s/.+/\\U$&/ ;
print $string . '!' ;" -- lifted whole from JD's original, except for
the missing "shebang &".
do shell script "perl -e " & quoted form of perl_script
The upshot of this is: use the appropriate technique for the task. The
exact limits depend on your personal tolerances, but the rule of thumb
I use is to use "perl -e" for anything less than 5 lines of Perl. It's
less code, and there's nothing to clean up afterwards. (For anything
that requires more than 5 lines of Perl, I usually don't use
AppleScript. :) )
--Chris Nebel
Apple Development Tools
P.S. to JD: Welcome back! How was your vacation?
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.