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

Re: [MacPerl-WebCGI] MacPerl Speed improvement



At 13:10 -0700 7/14/1999, Patrick Reed wrote:
>I'm using one of Matt Wrights CGI scripts from his book CGI/Perl
>Cookbook.  I'm Currently Running Appleshare IP Software on a G3 Server.
>My problem is this:  The script "Feedback.cgi" times out whenver I try
>to execute.  Any ideas on how speed up the processing times of Macperl?

I've never looked at the book, so I don't know anything about the 
script, but would assume from the name that it is a variant of his 
FormMail.cgi that let's visitors send you email off of an html form 
for one reason or another.

The first question is whether the script works at all? If you don't 
know for a fact that it is even running, then I'd suggest forgetting 
about forms and browsers for a while and focus on that:

1. Add the -w switch to the first line if it isn't already there and 
then do a syntax check in MacPerl (or in BBEdit using the Perl tools).
2. Comment out the existing code that parses the browser input and 
add new lines that provide hardcode values for your variables (e.g., 
$firstname = "Jeff"; $lastname="Dahmer";) and try to run it like that.
3. Look at the portion of the script that is supposed to do something 
with the variables. In FormMail.cgi, there is a subroutine called 
Send_Mail that assumes that you've already set a variable to point to 
a *unix* mail program like q-mail. I don't know what the script you 
are working with does in this regard, but suspect that you are going 
to have to hack it to either use the Net::SMTP module or pass the 
parameters to your smtp server via AppleEvents in some way if you 
actually want the output mailed to you rather than just flushed into 
a file on disk.

There isn't anything in a cgi like you are talking about that should 
take very long to execute if the script is working, so I doubt if 
there is a timing problem. For future reference, you might keep the 
following in mind when messing with cgi:

1. When starting from scratch, use the cgi.pm module to do most of 
the drudgery; you will then be able to test the script in interactive 
mode from MacPerl (or a command line in MPW or other environments) 
and provide name/value pairs.
2. Use the -w switch
3. When you are opening files, etc., don't use "or die $!" to deal 
with failures, use "or print" and print an error message into the 
browser in html.
4. Use $|= 1 to flush errors into the browser window before the 
server's error message masks them.
5. If you are dealing with forms, bear in mind that sometimes "GET" 
will work when "POST" does not for no apparent reason and that the 
form is the last thing that should be dealt with. You can test 
without a form (ordinarily) by manually typing in the parameters in 
the browser (e.g., 
www.mysite.com/cgi-bin/feedback.cgi?firstname=Jeff&lastname=Dahmer.) 
I think that this defaults to GET.
6. When running MacPerl cgi's I've often had problems with stalls 
that occur intermittently for no obvious reason, but involve 
AppleEvents errors. The cgi applet will essentially freeze and can't 
be cancelled, etc. I don't know why this happens and the same script 
will not have these problems when run under unix, so I imagine it has 
something to do with memory management or with the event manager 
crapping out.

Anyway, I hope that this helps you a bit.


Richard Gordon
--------------------
Gordon Consulting & Design
Database Design/Scripting Languages
mailto:richard@richardgordon.net
http://www.richardgordon.net
770.971.6887 (voice)
770.216.1829 (fax)

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org