Perl CGI Programming

CGI stands for Common Gateway Interface, is basically a set of standards that defines how the information is exchanged between the web server and the custom script.

Before proceeding with CGI programming in perl, first make sure that your web server supports the CGI functionality and it is configured to handle any CGI programs correctly. All the CGI programs to be executed by the web server are basically kept inside a pre-configured directory, called as CGI directory and by convention it is named as /cgi-bin. You .cgi extension to all the perl CGI files.

My First CGI Program in Perl

Here is a simple CGI program in perl, give you some basic idea about CGI programming in perl. This is hello.cgi file, kept in /cgi-bin/ directory.


print "Content-type:text/html\r\n\r\n";
print '<html>';
print '<head>';
print '<title>My First CGI Program in PERL</title>';
print '</head>';
print '<body>';
print '<h2>Hello World, This is my first CGI program in PERL</h2>';
print '</body>';
print '</html>';


Now if you click on the link, hello.cgi, here is the sample output produced:

Hello World, This is my first CGI program in PERL

Perl Online Test

« Previous Tutorial Next Tutorial »

Like/Share Us on Facebook 😋