Re: shell-perl problems
Re: shell-perl problems
- Subject: Re: shell-perl problems
- From: Walter Ian Kaye <email@hidden>
- Date: Fri, 19 Dec 2003 23:19:46 -0800
At 12:17a -0600 12/20/2003, John Fowler didst inscribe upon an
electronic papyrus:
Dear fellow scripters,
I am trying to write a script to "find" using regular expressions via
perl.
My handler so far:
set thestring to "DOCTYPE(.*)PUBLIC" --for example, just a test string
perlregexfind(theText, thestring)
on perlregexfind(theText, thestring)
try
set theResult to (do shell script "/usr/bin/perl -e '$thisvar=\"" &
(theText) & "\";$thisvar=~m/" & thestring & "/;print $1'")
--set theResult to (do shell script "echo " & quoted form of theText)
return theResult
on error thiserror
return thiserror
end try
end perlregexfind
When I submit a fairly straightforward text bite as theText, this
script seems to return the desired result. When I input a large block
of text downloaded (a web page), I get
"sh: -c: line 1: syntax error near unexpected token `<'
sh: -c: line 1: `/usr/bin/perl -e '$thisvar=\"<!DOCTYPE H....
I tried using "quoted form of theText" in the set theResult line
without improving the situation.
Can anybody point me in the right direction?
Umm... write the "large block of text" to a file instead?
Or somehow use STDIN?
John Fowler
PS on the web page
http://developer.apple.com/technotes/tn2002/tn2065.html, perl is called
with a -n thingie as well as a -e thingie. What does the -n do?
(Putting it into my script didn't help).
check the man page? ;)
-boo
_______________________________________________
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.