eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak


intro to Perl on Windows
Although Perl may have been born and raised in the Unix universe, the world's favorite practical extraction and reporting language has had, and has had for some time, an established home on Windows.

Led by such companies as ActiveState, Perl has grown steadily since mid 1995, adding both standard Perl functionality, as well as a host of Windows-specific functionality such as OLE and COM integration.

In fact, by now, any Perl developer can feel confident that the applications she writes on UNIX-based servers will run without hitch when moved to Windows-based servers. Even long-time porting nightmare problem cases such as the implementation of fork are being solved.

And there is reason to believe that Perl/Windows-integration will continue. That Microsoft itself is committed to supporting Perl is demonstrated by the fact that Microsoft has been a major funder of Perl on Windows development since development began. In fact, with the recent signing of a three-year funding agreement between Microsoft and ActiveState, there is no doubt Perl will be an integral part of Windows going forward.

If you are looking for more information on Perl for Windows, there are quite a few excellent sites around. The sites on the right include the following:
ActiveState Aldo Calpini's Perl Lab Evangelo Prodromou's Win32 Perl FAQ (Not Working)
Perl.com Robin's Perl for Win32 Page Roth Consulting Perl Page
Getting Started  
Whether you are simply wishing to begin an investigation of the core language and your platform happens be Windows or whether you wish to look at specific-Windows integration tools such as 1) OLE [ object linking and Embedding ] with PERL, 2) control of the Windows registry via PERL, 3) using PERL to write COM [ Component Object Model ] objects, 4) communicating with pre existing COM objects from PERL, or 5) facilitating data aware pages via the PERLscript and IIS [ Internet Information Server ], your starting point remains the same - the installation of PERL on Windows.

This article is intended as a guide to that process. Future additions will delve more deeply into the Windows-specific capabilities of Perl.

Before you start though, we have one warning. Installing Perl is not a "click here and you're done" process. In fact, packaging Perl for Windows is an iterative process. Because Perl is an incredibly active, vibrant and living language, not only does the core language itself undergo changes and new releases periodically, but the thousands of your fellow Perl developers constantly release new, free tools through archives such as CPAN. Thus, "installation" includes regular upgrades and your active attention to the world of Perl.

As we mentioned earlier, the organisation at the heart of Perl for Windows is ActiveState, and their home page is located at: http://www.activestate.com

Perl for Windows is available from the ActiveState site as a product called ActivePerl. At the time of this writing, ActivePerl is in release 522 and can be downloaded directly from http://www.activestate.com/ActivePerl/download.htm.

Windows users will want to download the Intel release, and as the download page notes, those who are installing the package under Windows 95 require DCOM for Windows, Available from the Microsoft Site. Whether you download the package using HTTP or FTP does not really matter. Either way, you'll get what you are after.

When you are done downloading, you'll have a self-extracting executable such as the file Api509e.exe shown in the figure below. To begin the installation process, just double click the file.

It is important to note that the installation of ActivePerl may not proceed correctly if your system has a previously installed version AND that version is in use by a process at the time you commence your installation. If that is the case, you may be presented with a warning dialog box.

If this happens, you should exit the installation process immediately. Close any services/applications that may be using Perl and try again.

If you are having trouble locating Perl-based services and you happen to be using Windows NT, you can get help by using:

Start->Settings->Control Panel->Services

Look through the list of services running on your machine to see if you can find one that may currently be using Perl. Terminate it/them, and then recommence your installation.

Most users of course will not have to worry about this problem. In fact, most likely, if you double clicked the self-extracting executable, you will now see the ActiveState license agreement.

After you have read and accepted the license, you will be presented with the "Installation Notes" screen. This screen informs you of all the different installation options that are available with ActivePerl. This page has a number of different headings, and some explanation regarding each.

The headings include:
Add the Perl bin directory to your path
Associate '.pl' with Perl.exe in Explorer
Associate '.pl' with Perl.exe for your Web server(s)
Associate '.plx' with Perl for ISAPI in IIS
It then asks if you have read and understand the notes. Let's make sure that you do!

Add the Perl bin directory to your path  
Oftentimes, it is convenient to be able to run the Perl executable from within a DOS session without having to explicitly specify in which directory Perl is installed. For example, suppose you just want to be able to type:

perl scriptname.plx

from the command line rather than having to type:

c:\perl\bin\perl.exe scriptname.plx

In order to do that, you need to let your computer know where perl.exe is located. And in order to do that, you need to modify the PATH environment variable. In this section, Perl is letting you know that it is going to automatically modify the PATH variable on your behalf.

Note that by including the Perl "bin" directory in your path also means that your computer will automatically know where other related programs are as well such as perldoc.

However, you should note the significance of the statement "...all other Perl directories to be removed from the PATH.". Bear in mind that after this installation, you will have to add to the path the location of any different installations of Perl that you may wish to use concurrently. However, most users will be satisfied with a single installation and will not need to worry about this.

Associate '.pl' with Perl.exe in Explorer  
This note is relatively self-explanatory. This option means that every time you double click on a file suffixed ".pl" in Windows explorer, your machine will use the Perl interpreter to execute the file. The behaviour you will see is that a "Command Prompt" window will appear, and the Perl script will be executed within it.

The practical effect of this can be seen after you have completed your installation of Perl.

Associate '.pl' with Perl.exe for your Web server(s)  
Associating the .pl extension with the Perl interpreter in Windows Explorer is convenient for you as a developer because you can more easily run scripts. However, if you are a web developer, you also need to associate the extension from the point of view of the web severs you are using. That way, the web server will have a better idea of what a Perl script is.

On a systems level, associating the extension with Perl.exe for your web server means that the installer will edit your windows registry that will instruct IIS to associate scripts with a ".pl" extension as being suitable for execution by the Perl interpreter.

More importantly, the standard error and standard output generated by Perl scripts will be printed directly to the browser. This is a core feature from the point of view of writing CGI [ Common Gateway Interface ] scripts.

Associate '.plx' with Perl for ISAPI in IIS  
The effect of this installation option is that the execution of Perl scripts through the web server will be optimised. ISAPI stands for Internet Server Application Programming Interface.

The way that the execution of Perl scripts by the web server usually works is that as a preliminary step to the execution of the script, the web server has to actually load the Perl interpreter into memory. It does this every time the CGI is called.

The use of ISAPI means that the web server has access to the Perl interpreter bundled as a runtime DLL that can be loaded once by the web server. Once loaded the interpret will persist in memory and not need to be reloaded for subsequent CGI calls. This functionality is only available if you have installed a web server that implements the ISAPI.

There are security/stability implications associated with running Perl in the same thread of execution as the web server [as opposed to starting a separate process to load the Perl interpreter and execute the CGI ]. However, aside from mentioning them, these matters are outside the scope of this article.

An associated point is that loading the Perl interpreter as a persistent DLL in the web server makes it even more important to close down IIS prior to installing a new version of ActivePerl.

Choosing an Installation Directory  
Answering "yes" to the "Installation Notes" screen will advance you to the "Choose Destination Location" Screen.

This screen allows you to select a root directory for the installation of Perl. The choice is entirely yours, but the default path is to be recommended from the point of view of installing subsequent versions of ActivePerl over the top of old versions.

One thing to note is that if you wish to regularly move Perl scripts between UNIX and Windows servers, it might be a good idea to create a "c:\usr\bin" directory and copy the contents of the c:\Perl\bin" directory into it. That way, you can use the same Perl header line in all your Perl scripts.

Selecting Components  
Once you have specified the installation path, you will be asked to choose which ActivePerl components you would like installed.

Most of these options have been explained above. However, we have not yet talked about PerlScript.

The PerlScript component gives you the ability to write web pages that contain embedded Perl code that the web server will be able to execute. In other words, you will be able to write ASP pages in PERL.

Perl Options Screen  
The next screen will query you regarding the addition of Perl bin to your path and the association of .pl files with Perl.exe in Windows Explorer and the web server.

We have already covered these topics above. Just notice that you can uncheck any of the boxes that you are not comfortable with.

Adding Perl to the Start Menu  
Next, the ActivePerl installer will create an icon on your Start menubar for its associated functions. This screen helps you select where you want this icon to be created.

Completing Installation  
Finally, the installer will provide a summary screen as a final check and ask you if it is okay to begin the installation process.

Clicking next will begin the installation process. Just wait while the installer does its work.

After the installation is complete, and you have/have not read the release notes, start a command prompt (DOS Shell) window. If typing "perl -v" prints out a message containing version information about your installation of Perl, then the installation process is successfully complete.

Now what?  
If you are a new Perl developer, you can get an excellent introduction to standard cross-platform Perl programming at The Introduction to Web Programming Tutorial and at The Introduction to Perl 5 Tutorial.

Otherwise, here is a quick demonstration of a very simple perl program written using Notepad and run from the DOS Shell.