CGI.pm is a large and once widely used
Perl module for
programming Common Gateway Interface (CGI)
web
Web most often refers to:
* Spider web, a silken structure created by the animal
* World Wide Web or the Web, an Internet-based hypertext system
Web, WEB, or the Web may also refer to:
Computing
* WEB, a literate programming system created by ...
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.
[https://metacpan.org/pod/distribution/CGI/lib/CGI.pod#CGI.pm-HAS-BEEN-REMOVED-FROM-THE-PERL-CORE] The module was written by
Lincoln Stein and is now maintained by Lee Johnson.
Examples
Here is a simple CGI page, written in Perl using CGI.pm (in
object-oriented style):
#!/usr/bin/env perl
use strict;
use warnings;
use CGI;
my $cgi = CGI->new;
print $cgi->header('text/html');
print << "EndOfHTML";
A Simple CGI Page
A Simple CGI Page
EndOfHTML
if ( my $name = $cgi->param('name') )
if ( my $age = $cgi->param('age') )
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') )
if ( my $age = param('age') )
print '