Mike Gossland's Perl Tutorial Course for Windows

Intro to CGI | First Page | Printing HTML | Serving HTML | Serving Edited

Chapter 5. Introduction to CGI

Introduction to CGI

The rest of this introductory Perl course will describe how you can make Perl interact with a browser through the Common Gateway Interface, or CGI.

CGI is a standard interface that sits between the web browser and the web server. When the browser makes a request of the server, all of the request details flow into the server through the input interface of the CGI. When the server responds with its output, the information flows back out through the output interface of the CGI.

When Perl responds to a browser request it sends output to STDOUT which is sent through CGI back to the browser. Because you know how to print data to STDOUT, you can already work with CGI at its most basic level: sending data to it. It is no more complicated than printing to STDOUT.

The real challenges are learning how to interact with the data that comes in, and how to create useful content. We will learn this later, but for now, we will start by printing some very simple text to a browser window.

If you have not yet installed a cgi-bin webserver and set it up to work with Perl, take the time to do it now. You won't be able to run the examples in the rest of the course unless you do.

Note that since this course was written in the early 2000's web technology has moved on from using cgi-bin scripts to create output. You can still do it, but this course no longer offers interactive scripts hosted on this server.