The image below shows how the whole procedure works in detail (you may have to widen your browser window to accomodate it)

Map of Interaction between HTML Scripts, HTML Server and Perl scripts

Mode of Action

The HTML tags for forms are embedded in your HTML page, just like other HTML tags. When the browser reads those it knows that the user is to be able to enter data.
Assuming this has been done, the browser posts the entire information back to what is called the HTML deamon. This program is called httpd and runs concurrently in the background (invisible to you, the user). A synonym for deamon is HTML server. The name deamon by the way, refers to mythical creatures, small imps guarding the entrance to hades !
The deamon analyses the incoming data and looks for an identifier telling it what program will deal with the request. In the sheet you have been given of geom.html, you will see the following line:

<form method="POST" action="/cgi-bin/">

This indicates that the deamon should send all information to the file which is located in the /cgi-bin directory. You may remember that the extension .pl indicates a Perl program. Perl is commonly chosen to interpret HTML forms because it is easy to write and modifiy and because it interfaces very easily with HTML ! The Perl CGI routines (and others) are easily available on the Web - this saves you from reinventing the wheel.

The Perl script contains instructions for Perl to extract relevant data and send it back to the server. Should the script need to interface with other programs or do something Perl does not per se understand, then the Perl interpreter looks in the Perl CGI library for the appropriate CGI routines. The programmer needs to include this library in the script with the following command (the syntax and result being similar to that of a C program):

require "";

Note that to receive data, Perl scripts must accept it from STDIN ; conversely, to output data they must send it to STDOUT. The Perl script need not echo data back to the server. It is also possible to start external programs - in the example above, I have shown that data could be rerouted to the geometry program.

To Next Page
Back to Index