 |
 |
 |
 |
    |
|

HTML documents are plain text files that live on a computer connected to the Internet, ready to be viewed. A Web server waits for and sends out those files in response to requests from Web browsers. There is nothing dynamic or interactive about these documents--they are "flat" files. If you want your site to do something dynamic or interactive, like handling information in an HTML form, you have to run a separate program outside your Web server. That's where CGI comes in--it's the interface between these applications and the Web server.
These external programs can do just about anything: handle incoming forms, grab records from a database, save data to a file, and so on. As long as you conform to the CGI specification, you have a wide choice of tools for writing your CGI applications. Typically, you use Perl (practical extraction and report language), although you can write CGI applications in just about any programming language, including Java and C/C++.
|
 |









 |
Because Perl is the most popular scripting language for building CGI applications, we'll use it for all our examples. The beauty of Perl is twofold: there's a Perl interpreter for just about every operating system on which you find a Web server, and Perl is uniquely powerful when it comes to manipulating text. But this isn't a tutorial on Perl, so make sure you have at least a basic understanding of the language before you dive into the examples. (Note: the Perl samples included in this story assume that you will be running your CGI programs on a Unix system. Please check with your ISP to make sure this is the case.)
If, after going through this introductory tutorial, you decide you want to delve further into Perl, there are tons of places on the Web that provide more information. We especially like www.perl.com, which offers links to archives of sample code, places to find the latest versions of the language, and so on. There are also plenty of books on Perl, but two titles from O'Reilly stand out. The first is Larry Wall's Programming Perl, also called "the camel book" because of the illustration on the cover. The other is Randal L. Schwartz's Learning Perl, commonly called "the llama book" for similar reasons.
|