Re: Do Perl Script?
Re: Do Perl Script?
- Subject: Re: Do Perl Script?
- From: Christopher Nebel <email@hidden>
- Date: Sat, 7 Jun 2003 20:26:54 -0700
On Saturday, June 7, 2003, at 04:04 AM, John Delacour wrote:
At 9:29 pm -0700 6/6/03, Christopher Nebel wrote:
Single quotes are not an issue with "quoted form".
Maybe not for you, but when I need such contorsions as this
set s to "can't"
do shell script "perl -e " & quoted form of ("print qq~" & s & "~")
they're an issue for me unless I'm out to win an obfuscation
competition.
Oh, now I see what you're on about. This isn't a problem with "quoted
form"; this is a problem of trying to quote something in Perl itself.
You'll have the same difficulty trying to create a Perl script file: no
matter what your quote character is, if it appears in the string,
you're hosed. Using that particular syntax, the best you can do is
pick something that's unlikely to be used. Of course, what "unlikely"
is varies from task to task and person to person -- for me, "~" turns
up surprisingly often in file names.
A more resilient technique would be to pass the string as a parameter,
like this:
set s to "can't ~twiddle~"
do shell script "perl -e 'print $ARGV[0]' " & quoted form of s
That way, it doesn't matter what characters occur in the AppleScript
string, because the shell passes it to perl as a single argument.
--Chris Nebel
Apple Development Tools
_______________________________________________
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.