top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to Install, Configure and run Perl on Windows

+2 votes

Perl does not come pre-installed with Windows. To work with Perl programs on Windows, Perl will need to be manually downloaded and installed. ActiveState offers a complete, ready-to-install version of Perl for Windows.


Click on the appropriate download link. You can leave the registration form blank and just hit continue to proceed. Download the windows msi installer. Run the installer. The areas of interest in the installer are the install location. If you are only running Perl on Windows machines, you can use the default location. If you also have Perl programs running on Linux or Mac OS X, you may want to change the install location to C:\usr. This will allow you to maintain portability in your programs. You can also check the box so that Perl gets added to the path, and check the box to create the perl file extension association. After the installer completes, you now have Perl on your machine.

Perl programs can be created using any text editor such as EditRocket. Perl programs and scripts typically end with the .pl extension. EditRocket will automatically recognize files with the .pl extension as Perl programs, and will color the syntax accordingly.

To create a Perl program, simply create a new file, such as In the file, place the following:

print "Hello World!";

Notice the first line of the file. Perl scripts should start with the path to Perl on the first line. The path to Perl should be the location where you installed Perl on your Windows machine.

The above script can be executed using the EditRocket Tools -> Perl -> Execute Program option, or you can execute it from a command prompt. To execute the script in the command prompt, use the cd command to cd to the directory where the file was saved, such as

cd C:\scripts 

If when installing Perl, you selected the option for Perl to be added to the path, type the following:


Hello World! should then be printed to the screen.

If Perl is not in your Path, you will need to type the full location of the perl executable to run the program, such as C:\Perl\bin\perl

Configuring Perl CGI in Apache:
The next step is to use EditRocket to open the httpd.conf apache configuration file located in the apache install directory in the conf directory. Search the httpd.conf file for the line

Options Indexes FollowSymLinks

Add ExecCGI to this line. The line should now look like the following:

Options Indexes FollowSymLinks ExecCGI 

Next, search for the following:

#AddHandler cgi-script .cgi 

Uncomment this line by removing the # in front of the line, and add a .pl to the end of the line. The new line should look like this:

AddHandler cgi-script.cgi

Now, the apache web server needs to be restarted. You can do this either via the Apache service located in the services control panel or via the Start -> All Programs -> Apache . . . -> Control Apache Server menu option. Once apache is restarted, you can run a test page to make sure everything is working correctly.

Running a test Perl CGI script:
You can create a new Perl test page in EditRocket by selecting File - New From Template - Perl - Sample Web Page. This will bring up the following in a new editor tab:

print "Content-type: text/html; charset=iso-8859-1\n\n";
print "<phtml>";
print "<body>";
print "Test Page";
print "</body>";
print "</html>";

Make sure to change the !#/usr/bin/perl to the location that Perl is installed on your machine. By default, it would be #!/perl/bin/perl The new file should look like the following:

print "Content-type: text/html; charset=iso-8859-1\n\n";
print "<phtml>";
print "<body>";
print "Test Page";
print "</body>";
print "</html>";

You can now save this file as to the htdocs directory under your apache installation directory. You can access the page by entering the URL of your local apache server in a web browser. If you are running apache on a port other than port 80, make sure to include :port_number after the localhost:

posted Apr 7, 2014 by Rajni

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.