Perl & CGI



This is a brief explanation of PERL and CGI.  If you have, or want to put up your own web site, you have heard of HTML, Javascript, Java, and CGI. CGI stands for Common Gateway Interface. Unlike Javascript, HTML, and Client Side Java, the CGI is a program written in any programming language that runs on the server side and not on the client side. Client meaning your web browser. CGI is the part of your web site that communicates with other applications running on your server.

The main purpose of writing CGI applications or scripts is to give you more interactivity on your web site. Many web sites are static, and do not allow for much user interaction, while others have guestbooks, image counters, allow you to place orders, access databases, and other useful applications.

This is where CGI comes in. In order to get this type of interactivity you must have an application running on the server that will allow you to process the users input or do any other task that you want. As I mentioned, CGI scripts can be written in any language. The most commong language the CGI scripts are written in is PERL and C. PERL is the preferable language when writing CGI scripts because of PERL's strength in string manipulation. Although, Java is gaining popularity in providing interactivity, without the use CGI.

CGI programming is nothing more than programming with some special types of input and a few very strict rules for program output. When a user fills out a FORM (a subset of HTML that allows the user to submit input) the server sends the form input to the specified CGI, which in turn parses the entered data and uses it in a specified manner, and returns HTML with an answer to the users request. You can find a variety of examples of CGI's all over the web, I have also written certain CGI programs for those who wish to learn how to program CGI scripts.

When choosing a language to write CGI scripts in, the language should:

PERL satisfies all the above requirements, thereby making it a very good language for CGI programming. If you want to write your own CGI scripts, I would suggest that you first learn PERL, and use PERL for CGI scripting, you will find that it will make your life a lot easier. If you want to get more detail on CGI and how it works I suggest getting a book or looking at the CGI specification on the NCSA site. I hope that this small explanation of CGI has helped you get an understanding of what is and how PERL is very well suited for writing CGI applications.


<---
Return To Perl Page
1