CGI Scripting
Perl CGI Index
Basic CGI Scripting
Simple CGI Demo
Styling CGI Output
Sharing Perl Code
CGI Code Suite
CGI Environment
Next section...
Web Applications
Demo Source Code
Example #1 source
Example #2 source
Example #3 source
dwd.pm (#3) source
Example #4 source
dwd.pm (#4) source
dwd.conf source

CGI Scripting

CGI Code Suite

So far we have seen the principle of modular code applied at all levels of the website design process up to and including the CGI programs. Within the scope of the example CGI program shown so far the idea of setting up modules and code environments is overkill...

However, the principle is vital when designing a website with more than a few CGI programs, especially if they are intended to interact with each other whilst seamlessly matching the appearance and standards of the rest of the website.

Despite the wide variety of applications all CGI programs perform essentially the same tasks:
initialise - receive input - check it - process it - output a result.

Within the program some of the code will relate to the program environment and some to the program specific function and output. With some careful planning it is possible to code your programs so that these different aspects can be separated.

By removing the program environment related code to separate shared subroutines the programs become simple shells for web-applications with all 'higher' functions taken care of. All of the technical functionality of the program and its inter-relationship with the webserver is now handled by a handful of functions, themselves in a single accessible location, the shared perl module for the site.

There are a number of key functions that can be treated in this way, each is discussed in detail in the next article...

All of the ideas given here are fairly simple, yet combined acording to the needs of your website they provide a very robust environment and stable platform upon which to base the rest of your code, and once you have these routines established and working you can forget about then to concentrate on the 'proper' coding for the dynamic pages themselves.

These ideas have been implemented in the next version of our example program; »Temperature Converter v4, see the sidebar links for v4 source code...

Show Style-Switcher...