[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Millions of Questions from a Newbie



>OK,
>
>I got MacPerl 5.06.
>I got MacHTTP 2.2.
>I got MPCGI 0.6.
>
>I also have AppleScript 1.1 and a thing called CGI OSAX.
...
>
>So, if I set up MacHTTP, had an internet connection, got MacTCP, and was
>all ready to go to have a form to gather information from a visitor to my
>site what's the best program to use to gather the information?
>AppleScript? MacPerl? I don't want to learn a language and realize I
>should have learned the other one.

Here's my $.02, based on my experiences with AppleScript and MacPerl.  Note
that my command of AppleScript syntax may be a bit rusty, and that I will
use "-," to represent that little line-continued doohicky that AppleScript
uses.

AppleScript                           MacPerl
-------------------                   ------------------
print "<a href=" & quote & -,         print "<a href=\"http://www.iup.edu\">"
   "http://www.iup.edu/" -,
   & quote & ">"

needs shareware osax to do            built-in GUSI, supports neat web
   TCP/IP stuff                         tools like MOMspider and email

easy to read, syntax sometimes        easy to write (once you learn it),
   quirky                                always quirky :) but consistent

special cgi osax available            special cgi libraries available

can do string operations like         can do string operations like global
  concatenation                          search-and-replace with wildcard
                                         pattern-matching (plus everything
                                         AppleScript can do)

built in to System 7.5                takes up application memory

always slow                           can be quite fast for operations
                                         involving pattern-matching and
                                         grep-style substitutions

can read and write disk files         can read and write disk files, and
                                         includes support for indexed
                                         database files

Well, I'm not getting paid for this, so enough of the high tech lab reports
;)  Bottom line is that I wish MacPerl supported the Threads Manager so it
would run a little faster, but other than that, I have become a big fan of
MacPerl and haven't written an AppleScript cgi in ages.  (Plus there's a
ton of already-written perl stuff out there that is mostly portable to the
Mac.)

>Also, what exactly *happens* when a script is run? In the HTML, the
>ACTION is set to a CGI, correct? Does MacHTTP run the specified script?
>Does MacPerl or AppleScript have to be running at the same time in order
>for the script to run?

Let's say the end user is looking at an HTML form that specifies your cgi
as its ACTION.  What happens when the user clicks on the "Submit" button is
that the user's client looks at all the fields on the form and bundles up
whatever is there into one big blob of text and shuffles it off to your
server, along with the path for your cgi.  The server, upon receiving this,
fires up your cgi script, and sends it an AppleEvent containing the "blob"
of text with all the fields from the form.  Presumably, your cgi then runs
one of the standard cgi utilities to turn that blob back into some kind of
ordered list of field names and field values, and then processes it.  When
your cgi is done, it sends a MIME-encoded reply via an AppleEvent back to
the server, and the server then hands that reply back to the user's browser
program.

Don't worry about the AppleEvents.  Both AppleScript and MacPerl handle
that transparently, and you never really even need to know that AppleEvents
are involved (unless you try to send back more data than will fit in a
single AppleEvent--then you *do* need to know a little bit ;).  You need to
know how to send back a MIME-encoded response, which in oversimplified
terms means that your first line needs to be something like

content-type:  text/html

(or text/plain, for plain text files).  But I'm starting to go on and on.
I'll stop here and see what you want to ask about next, and I'm sure others
will have comments on my highly subjective comparison of AppleScript and
MacPerl.

-----------------------------------------------------------------------------
Mark Nutter                           Internet: manutter@grove.iup.edu
College Technology Systems Manager      BITNET: MANUTTER@IUP
ACS/College of Fine Arts                   WWW: http://www.iup.edu/~manutter/
G-4 Stright Hall, IUP
Indiana, PA 15705
"Prejudice is what keeps us from seeing that every member of the human species
is a person with human rights equal to our own."
=============================================================================