HOME

TheInfoList



OR:

CGI.pm is a large and once widely used Perl module for programming
Common Gateway Interface file:Common Gateway Interface logo.svg, The official CGI logo from the spec announcement In computing, Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program to process HTTP or HTTPS ...
(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 An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
for receiving and processing user input. There are also functions for producing
HTML Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
or
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages which mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, pr ...
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.


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''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impleme ...
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


References


External links


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