HOME

TheInfoList



OR:

CGI.pm is a large and once widely used
Perl module A Perl module is a discrete component of software for the Perl programming language. Technically, it is a particular set of conventions for using Perl's package mechanism that has become universally adopted. A module defines its source code to ...
for programming
Common Gateway Interface In computing, Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program, typically to process user requests. Such programs are often written in a scripting language and are commonly re ...
(CGI) web applications, providing a consistent
API An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
for receiving and processing user input. There are also functions for producing
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaSc ...
or
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
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 Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of p ...
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

Name:
Age:


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 ''; Note: in many examples , short for query, is used to store a CGI object.


See also

*
mod_perl Mod, MOD or mods may refer to: Places * Modesto City–County Airport, Stanislaus County, California, US Arts, entertainment, and media Music * Mods (band), a Norwegian rock band * M.O.D. (Method of Destruction), a band from New York City, US ...


References


External links


CGI.pm
– at the
CPAN The Comprehensive Perl Archive Network (CPAN) is a repository of over 250,000 software modules and accompanying documentation for 39,000 distributions, written in the Perl programming language by over 12,000 contributors. ''CPAN'' can denote eit ...
Perl modules {{unix-stub