CGI.pm
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.
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. !/usr/bin/env perl use strict; use warnings; use CGI; my $cgi = CGI->new; print $cgi->header('text/html'); print A Simple CGI Page A Simple CGI Page Name: Age: EndOfHTML if ( my $name = $cgi->param('name') ) { print "Your name is $name. "; } if ( my $age = $cgi->param('age') ) { print "You are $age years old."; } print ' '; 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: !perl use strict; use warnings; use CGI qw/ :standard /; print header('text/html'); ... HTML output same as above example if ( my $name = param('name') ) { print "Your name is $name. "; } if ( my $age = param('age') ) { print "You are $age years old."; } print ' '; Note: in many examples , short for query, is used to store a CGI object. ==See also== mod_perl ==References== ==External links== CGI.pm – at the CPAN
References
No reference rows published for this article.
Cite this article
MLA
"CGI.pm." encyclopegia.org, 2026, https://encyclopegia.org/wiki/cgi-pm. Accessed 24 November 2026.
Chicago
"CGI.pm." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/cgi-pm.
APA
encyclopegia.org. (2026). CGI.pm. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/cgi-pm
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON