nlafferty has asked for the wisdom of the Perl Monks concerning the following question:

I have a program the I want to combine into one single cgi file. It basically is a search program for a database (Postgres). Let me break it down a little:

SCRIPT 1: Determines whether the user logged in is a NORMAL USER or ADMINISTRATOR. Then, if it's the ADMINISTRATOR it generates a form with a username field and dropdown for dates. If it's a NORMAL USER it defaults to that username and generates a form with only a 00-00-00 to 00-00-00 dropdown.

SCRIPT 2: This is the admin script for processing the data from the admin search form that script 1 generates

SCRIPT 3: This processes the normal user form generated by script 1.

All of these are broken down in subroutines except where a few variables are defined and were i determine the USER.
Should i even put these in a subroutine? And can i have if-elsif-else statement inside of larger if-elsif-else statments? Thanks, Nick

Replies are listed 'Best First'.
Re: 2 forms and 2 processes
by dga (Hermit) on Aug 09, 2001 at 19:55 UTC

    I usually keep the form reader and displayer in the same cgi file if the form is redisplayed when it gets input so it can collect more input basically in a loop. A lot of the code is common like collecting user credentials etc. Of course if you collect and categorize these credentials a lot then maybe you really want to make up a module you can call for this to make all of your scripts smaller...

    But see here for a discussion of large CGI scripts.

    Custom modules for a similar kind of thing are most recently discussed here

    You can nest if blocks into other if-elsif-else block and the {}'s which are required in Perl keep it obvious which block goes with which condition. Do try to keep it as straight forward as possible for your own sanity later though.

    Update: Found info on how to link nodes and implemented it.