Sunday, January 31, 2010

Perl CGI programming in windows



  Perl CGI programming can be done in Windows/UNIX. The below instructions tells about the CGI perl programming in windows.  
   Before trying CGI, we need to have the set up necessary for the CGI programming.  The following are the things needed for it:
1. Active Perl Installation
2. Apache web server
  
    With Active Perl, once can work with all the command line Perl programs. However, for the CGI programming, we need the Apache web server(xampp). Download the latest version of xampp and install it. Both these are easily available on Internet.

  Once the Apache (xampp) intallation is done, click on the link, http://localhost/xampp/  , to confirm whether the installation is sucessful or not. On clicking this link, the status of the Apache can be known. If an error exists, the installation is not successful.

   Once done, create a folder "cgi-bin" in the "xampp" directory. xampp directory will be in the place in which you chose the installation of xampp to be done.  Create a sample cgi program and place it inside the "cgi-bin" folder.

 Let  us see the example of a sample 'Hello World' program. The following are the contents of the program:
  

#!C:\perl\bin\perl.exe -wT
print "Content-type:text/html\n\n";
print "hello world";

[Note: The first line indicates the path of the Perl exe. Depending on your path, modify it accordingly].

 Save the above snipped as test.cgi  .Open the Internet explorer, and type  "http://localhost/cgi-bin/test.cgi".

  You should see the 'hello world' text on your browser screen.





No comments:

Post a Comment