Re: ACGI form parsing in OSX?
Re: ACGI form parsing in OSX?
- Subject: Re: ACGI form parsing in OSX?
- From: Reinhold Penner <email@hidden>
- Date: Fri, 1 Feb 2002 11:51:16 -1000
Chris Nebel was kind enough to set me straight on the use of perl in a
do shell script. I don't know why he didn't send this to the list, but I
find this such a great way of manipulating text that I'd like to forward
his comments:
From: Christopher Nebel <email@hidden>
Date: Fri Feb 01, 2002 09:20:50 AM Pacific/Honolulu
To: Reinhold Penner <email@hidden>
Subject: Re: ACGI form parsing in OSX?
On Friday, February 1, 2002, at 09:38 AM, Reinhold Penner wrote:
'just a test' | perl s|%([a-fA-F0-9]{2})|chr(hex($1))|ge
--> badly placed ()'s.
I really don't know where the problem is, since this thing works just
fine in my Perl script and the parens look fine to me.
Er, aside from the fact that that's a completely bogus shell script?
The stuff after the "perl" is valid Perl [1], but you're not using
appropriate options to pass it to perl, so it's going to be interpreted
by the shell. Try this:
do shell script "echo 'just a test' | perl -pe 's|%([a-fA-
F0-9]{2})|chr(hex($1))|ge'"
--> "just a test"
--Chris Nebel
AppleScript Engineering
[1] ...though I didn't think so at first. I didn't know you could use
Perl expressions in a substitution command like that.
Thanks to Chris, now we can use some cool regexp commands in the shell
without any osax.
The greatest thing about this is that you can pass a completely bogus
shell script to the Applescript-Users list and it will return a properly
corrected version of it :-)
-Reinhold
-- Live prosper and may the Shell be with you