CGI Programming with Perl

CGI Programming with Perl

The Common Gateway Interface

HTML is a markup language

Cannot by itself:

A wide variety of Web sites require interaction with the user

This requires the browser to access the software resources of the server

These server-based programs communicate back to the client through HTTP with HTML documents

The interface between a browser and software on the server is called the Common Gateway Interface



A request to run a CGI program is like any other HTTP request

except that the requested file can be identified by the server as being a CGI program

Identifying CGI by their address on the server or by their filename extensions

When a server receives a request for a CGI, it does not return the file, it executes it



The results of a CGI program execution can take many different forms

It could produce just the URL of an existing document

Most often an HTML document is returned

  1. An HTTP header

    • If the document is going directly to the client, the header must be complete


    • If the document is going through the server, the header can be partial --it is completed by the server


  2. A body which can be:

    • Plain text


    • HTML


    • image file


    • audio file



Common for users to interact with the server through forms

The browser presents a form to the user

The user is asked to fill in the boxes and to click the buttons of the form

The user submits the filled-in form by clicking the submit button on the form

The content of the form are encoded and transmitted to the server

The server must use a program to:



Both CGI programs and client-side scripts support dynamic documents

Client-side scripts cannot access files and databases on the server