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

Re: [MacPerl] How To Scripts



At 23:50 -0500 6/22/1999, ken towry wrote:
>These are the scripts I'm having trouble with from the book "Perl 5 How
>To".
>Unfortunately, who ever is responsible for this book was cheap and they
>didn't include the text on the CD-ROM or the website, so i had to enter
>it in, may contain a few typo's. I did a syntax check and it returned no
>errors. Iv'e also included the parsehtm.pl in it's entirety at the end
>of this email.

I didn't mean for you to take the time to manually enter the entire 
thing, I was just wondering what we were trying to do. I share the 
opinion of others that the file open construct is just wrong- if you 
use the -w switch when you check syntax, you will get a warning about 
this (along with another one that is inconsequential). It may run, 
but it isn't going to do what you expect it to do.

If I may offer a general observation about cgi, it is that there is 
by definition a lot of interaction involved between different things 
and lots of stuff that can break. For instance, even if the script(s) 
that you are dealing with were perfect, you would still get nowhere 
if the html of the form calling them was bad- assuming that it isn't 
a typo, I question whether the

<FORM METHOD="POST" ACTION="http:///cgi-bin/form pl">

line that the authors provide would actually do much of anything. You 
could use "http://www.myServer.com/cgi-bin/form.pl" or just 
"/cgi-bin/form.pl" but I've never seen the format they offer and, on 
my server, it breaks.

My point is that the best way to develop a cgi is to begin by just 
treating it as an ordinary script and running it in MacPerl until the 
output looks close to what you expect. This may mean either packing 
your input variables with some static test values or (better) using 
CGI.pm so that you can interactively provide these values. Do not 
bother with servers or forms until this seems to work, then take 
whatever steps are still necessary to make it act like a cgi and put 
it on the server. Test it by manually calling the url from your 
browser with whatever input values it requires (e.g., 
http://www.myServer.com/cgi-bin/myScript.cgi?name=Mini-me&height=short 
). Embed some print statements at different points so that you can 
tell whether the script is running at all and how far it got if it 
craps out. Once that's working, then worry about setting up a form to 
call it.

The book's authors are asking you to bite off an awful lot at one 
time. If you try to do everything at once, then I can absolutely 
promise you that it is not going to work the first time around and 
that you will waste a lot of time trying to figure out why. Good 
luck, but this approach may be more frustrating than instructive.


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-request@macperl.org