CGI - Perl

CGI (Common Gateway Interface)

The Common Gateway Interface is a standard way for a Web server to pass a Web user's request to an application program and to receive data back to forward to the user. When the user requests a Web page (for example, by clicking on a highlighted word or entering a Web site address), the server sends back the requested page. However, when a user fills out a form on a Web page and sends it in, it usually needs to be processed by an application program. The Web Server typically passes the form information to a small application program that processes the data and may send back a confirmation message. This method or convention for passing data back and forth between the server and the application is called the common gateway interface (CGI). It is part of the Web's Hypertext Transfer Protocol (HTTP)

If you are creating a Web site and want a CGI application to get control, you specify the name of the application in the "Uniform Resource Locator" (URL) that you code in an HTML file. This URL can be specified as part of the FORMS tags if you are creating a form. For example, you might code:
and the server at "" would pass control to the CGI application called "" to record the entered data and return a confirmation message. (The ".pl" indicates a program written in PERL but other languages could have been used.)

The common gateway interface provides a consistent way for data to be passed from the user's request to the application program and back to the user. This means that the person who writes the application program can makes sure it gets used no matter which operating system the server uses (PC, Macintosh, UNIX, OS/390, or others). It's simply a basic way for information to be passed from the Web server about your request to the application program and back again

Because the interface is consistent, a programmer can write a CGI application in a number of different languages. The most popular languages for CGI applications are: C, C++, Java, and PERL

An alternative to a CGI application is Microsoft's Active Server Page (ASP), in which a script that is embedded in a Web page is executed at the server before the page is sent


Perl or Practical Extraction and Report Language is a family of script programming languages that are similar in syntax to the C language, including Perl 5 and Perl 6 . Perl is an open source, general-use, interpreted language. In general, Perl is easier to learn and faster to code in than the more structured C and C++ languages

Perl programs can, however, be quite sophisticated. It is often used for developing common gateway interface (CGI) programs because it has good text manipulation facilities, although it also handles binary files. Perl includes a number of popular UNIX facilities such as sed, awk, and tr. It can be compiled just before execution into either C code or cross-platform bytecode. When compiled, a Perl program is almost as fast as a fully pre-compiled C language program. A plug-in can be installed for some servers, such as Apache, so that Perl is loaded permanently in memory, thus reducing compile time and resulting in faster execution of CGI Perl scripts

CGI and Perl Resources

Perl Tutorial Hub
An authoritative list of recommended tutorials

Perl for Perl Newbies Series
Contains verbose slides filled with explanation, examples and anecdotes. Covers a basic subset of Perl

The Perldoc Tutorials
The tutorials that ship as part of the perl core. Start with perlintro and then continue with other tutorials
Beginners Introduction to Perl. A 6-part tutorial that covers the basics. this tutorial should get you started

Perl Maven
Perl and CGI script with Apache2

LPW: Beginners Perl by Dave Cross
Presentation slides by Dave Cross

Perl One-Liners Explained by Peteris Krumins
A series of posts about useful perl "one-liners" that may serve as a teach-by-example

Common Gateway Interface CGI documentation
Introduction, primer for getting started, interface spec, tutorial for writing ErrorDocument. Examples of behavior and programs

CGI Made Really Easy
Tutorial for writing CGI scripts to process Web forms. In English or German

CGI Programming 101
A course intended for anyone who knows HTML but doesn’t know Perl or CGI programming

Instantaneous Introduction to CGI Scripts and HTML Forms
Detailed explanation of CGI forms, how to use them and the mechanics behind how they work

Kali Linux Tutorial: What is it? How to Install it. How to Utilize it

CGI and Perl Scripts
Thousands of scripts and software for websites and web developers. PHP, Perl, CGI, MySQL, WebApps, SaaS

Matt's Script Archive
Free Perl CGI Scripts
Free Perl and CGI Scripts

The Perl Archive’s Guide
Listing nearly 4,000 cgi and perl programs

nms Project: Web Scripts Written by Experts
nms is a set of CGI scripts that are intended as drop-in replacements for the scripts at Matt’s Script Archive

Tweet  Share  Pin  Tumble  Email