Chapter 18.  CGI Programming

Unless you’ve been holed up in a log cabin without electricity for the last few years, you’ve heard of the World Wide Web. Web addresses (better known as URLs) pop up everywhere from billboards to movie credits, from magazines and newspapers to government reports.

Many of the more interesting web pages include some sort of entry form. You supply input to this form and click on a button or picture. This step fires up a program at the web server that examines your input and generates new output. Sometimes this program (commonly known as a Common Gateway Interface (CGI) program) is just an interface to an existing database, massaging your input into something the database understands and massaging the database’s output into something a web browser can understand (usually HTML).

CGI programs do more than process form input. They are also invoked when you click on a graphic image and may in fact be used to provide whatever output that your browser sees. Instead of being dull and boring, CGI-enabled web pages can be marvelously alive with dynamic content. Dynamic information is what makes the Web an interesting and interactive place, and not just a way to read a book from your terminal.

Despite what all those bouncing balls and jumping adverts might lead you to believe, the web contains a lot of text. Because we’re dealing with text, files, network communications, and a little bit of binary data now and then, Perl is perfect for web programming.

In this chapter, ...

Get Learning Perl on Win32 Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.