Perl

Perl guide by pcdinh (Written in English for fun :D) 

Perl is included by default in Linux distros so it is nonsense to talk about an installation procedure in this platform/environment. This installation guide is well tested in my PC computer: Windows XP SP2, Apache 2.2, PHP 5.3 dev, Java 6.0 build 10, Netbeans 6.0, Glassfish 2, Tomcat 6, MySQL 5.1.

Installation

Download

ActivePerl (Windows (x86) MSI version) from http://www.activestate.com/store/activeperl/download

Install the binary

Run the MSI file and install the binary into C:\server\perl or any directory you want. It is not important so it is up to you and your demand to choose a suitable directory path.

Configure Apache 2.2 to know Perl presence

Find the line

Options Indexes FollowSymLinks

in the document root directory directives <Directory "D:/webroot"> and change it to

Options Indexes FollowSymLinks ExecCGI

You just appended ExecCGI at the bottom of that line only.

Enable the use of CGI scripts outside C:\server\Apache2.2\cgi-bin [Optional]

You need to uncomment the following line

#AddHandler cgi-script .cgi

that locates in <IfModule mime_module>. If you want to use Perl extension .pl together/along with .cgi common extension, you need to add .pl behind .cgi in the same line but the order is not important. That line should be read as follows:

AddHandler cgi-script .cgi .pl

If you want to create your own cgi-bin directory, you may want to comment out the line ScriptAlias /cgi-bin/ "C:/server/Apache2.2/cgi-bin/" and change the directory to any one you wish such as ScriptAlias /cgi-bin/ "D:/webroot/cgi-bin/"

Test it out

Create a plain text file with the following content

#!C:/server/perl/bin/perl
print "Content-type:text/html\n\n";
print "Hello Perl. Welcome to PHPVietnam Group headquarter";

and name it hello.pl and save it to the script alias directory such as C:\server\Apache2.2\cgi-bin

Restart your Apache 2.2 first. Now open the browser and browse to http://localhost/cgi-bin/hello.pl

It should work.

Perl language features