Installing Perl on Windows XP

Installing Perl on Windows XP is quite simple. This article contains installation instructions, configuration tips, and other useful information.

Downloading Perl
You can download the latest version from ActiveState.com. Choose the Windows MSI download. The latest version at the time of the printing of the article is 5.8.8. The downloaded file should have a .msi extension.

Installing Perl
Double-click on the downloaded file to install the software. The following two options should be checked:

Add Perl to the PATH environment variable
Create Perl file extension association

Configuring Perl and CGI
Open Apache's httpd.conf file for editing. If you don't know how, refer to Installing Apache on Windows XP.

Change the following line:

Options Indexes FollowSymLinks
to
Options Indexes FollowSymLinks ExecCGI Includes
Then uncomment the #AddType text/html .shtml and #AddOutputFilter INCLUDES .shtml by removing # characters. This modification would enable CGI and SSI.

Then change:

#AddHandler cgi-script .cgi
to
AddHandler cgi-script .cgi .pl
then comment ScriptAlias line by addina a # character in front. This modification would allow you to run cgi scripts with .cgi and .pl extensions outside cgi-bin folder.

Restart Apache.

Hello Perl!
Now its time to test the installation and configuration. Use notepad and and save the following example in Apache's working directory as hello.pl. My directory is c:/public_html. If you are confused, refer to Installing Apache on Windows XP.

#!c:/perl/bin/perl
use CGI qw(:standard);
use strict;

print header;
print "<b>Hello Perl!</b>";
Make sure Apache is running. Use your browser to view http://localhost/hello.pl. You should see Hello Perl. If you get an error message, refer to your apache error log. It is located at your_apache_installation_folder/logs/error.log.

Debugging Errors
To debug your Perl scripts, you would need to run your scripts from the command line. To do so go to Start --> Run --> type cmd and click on OK. In the command line window, use cd command to go to c:/public_html (your working directory). Type perl hello.pl and hit enter.