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

[MacPerl] Qtn: Structure of CGIs?



Howdy!

I'm putting together a CGI script that does a lot of processing to some form
args and I'm wondering how I should structure the script to be most
efficient. The script is to take form input and do several things with it:

1. Parse the args into a hash (first name, last name & e-mail)
2. generate a username & password based on name
3. compare username with a file, and modify (by increment) if necessary
   (ie jsmith becomes jsmit1, jsmit2, etc. if matches are found)
4. store hash into two different db files (one's the pw file, one's tracking)
5. e-mail username & pw to applicant
6. last, but not least, return an HTML doc. saying "thanks for submitting..."

In order to make various parts of the script fairly portable, I'm trying to
modularize this into subroutines as much as possible (pretty much each
number above is a separate subroutine - although I might combine 2 & 3). Now
- the clencher - Should I have the script call the return HTML subroutine
first? Especially since none of the data from the form is to be returned in
the HTML. I'm just wondering if there's a problem with the HTTP response if
that'll cause the script to fail - I'm thinking that to ensure against this,
I can do #6 last (after it's verified that all of the other stuff went off
without a hitch), but that may take a bit of time, and efficiency is key
(especially on a Mac, where CGIs can quickly bog down the CPU). Should I not
worry about this, and put the HTTP response first in the queue, or is it
really not a factor?

After reading back over this, I suppose this is more suited to a general
Perl list than to the Mac-specific functions of Perl - sorry about that. If
I'm outta line here, just let me know, and I'll take this to the appropriate
place.

Thanks in advance,
Daniel

Daniel Hedrick                                 mailto:daniel@icorp.net
InterCommerce Corporation                        http://www.icorp.net/
----------------------------------------------------------------------
            *-*-*-*-*-Wednesday, September 4, 1996-*-*-*-*-*
(1957) Ford Motor Co. introduced Edsel 
(1888) George Eastman patents 1st roll-film camera & registers "Kodak"
 (476) Romulus Augustus, last Roman emperor in west, is deposed