How CGI Works

A CGI script is a program, and most CGI programs are straightforward and written in C or Perl, two popular programming languages. Listing 28.1 shows a standard "Hello World" example in C.

Note

CGI programs are often called scripts because the first CGI programs were written using UNIX shell scripts (bash or sh) and Perl. Perl is an interpreted language, somewhat like a DOS batch file but much more powerful. When you execute a Perl program, the Perl instructions are interpreted and immediately compiled into machine instructions. Some other languages, such as C, are compiled ahead of time, and the resulting executable isn't normally called a script. Compiled programs usually run faster but are harder to modify.

In the CGI world, however, ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 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.