CGI programs can send many types of data or media, like documents, images, audio clips, etc. Most Web sites use CGI with fields for input and deals of dynamic content on the Web is done mainly using CGI. It is a method through which a web server can get/send the data from/to databases, documents, and other programs respectively, and then present that data to viewers through the web. In the above figure, with the help of HTTP (Hyper Text Transfer Protocol) web browser which is running on client machine exchanges information with the web server. Since, CGI program and web server normally run on the same system on which the web server resides, depending on the request from the browser, web server either provides the document from its own document directory or executes a CGI program.
Simple CGI Program:
Here is a simple program to understand the working of CGI Programming in Perl. Here, we will be getting inputs in the HTML program and then run the CGI script for the resulting web page. Since, HTML determines a number of input fields which we can use for passing the user data to the CGI program. Here, is the HTML form that makes use of these input fields like text field, scroll-down list, check-boxes and a submit button too for submitting the user data to the web server.