CGI.pm is a large and once widely used Perl module for programming Common Gateway Interface (CGI) web applications, providing a consistent API for receiving and processing user input. There are also functions for producing HTML or XHTML output, but these are now unmaintained and are to be avoided. CGI.pm was a core Perl module but has been removed as of v5.22 of Perl. The module was written by Lincoln Stein and is now maintained by Lee Johnson.
In 1993 the CGI specification was formalized to standardize how web servers could execute external programs and scripts; instead of just serving static files, they could generate dynamic content.ÃÂ In response to individual requests, CGI scripts could process user input and generate new HTML pages on the fly.
CGI.pm was written by Lincoln Stein to simplify not only the process of correctly capturing information and data sent to a web site, but also generating the new HTML content in the response.
Before the advent of this module, creating a CGI script from scratch required writing code that could:
In contrast, the various methods and functions available in CGI.pm allowed one to create a Perl script that automated a great deal of the more tedious coding (see examples below). Many of the largest and most well-known web sites and Web Apps relied on CGI.pm when they were first launched: EBay, IMDb, CPanel, Slashdot, Craigslist, Ticketmaster, Booking.com, TWiki, Bugzilla, Movable type, and LiveJournal. . However, in the interim, as web development toolkits expanded and evolved over time, these sites eventually migrated to using other programming languages and frameworks. ,
Here is a simple CGI page, written in Perl using CGI.pm (in object-oriented style):
This would print a very simple webform, asking for your name and age, and after having been submitted, redisplaying the form with the name and age displayed below it. This sample makes use of CGI.pm's object-oriented abilities; it can also be done by calling functions directly, without the , however the necessary functions must be imported into the namespace of the script that requires access to those functions:
Note: in many examples , short for query, is used to store a CGI object.