Perl CGI: The Happy Path: Installing Perl

Prepared by Bill Kilgallon, Bill@KilgallonFamily.com

First, you have to get Perl for windows (it is already installed on any self respecting Unix system). The windows port of Perl is built by Active State, and is freely downloadable from their website. I have included a CDRom for the bandwidth challanged members of the class (it's pretty big), and these instructions assume you are installing from the supplied CDRom.

First, you have to install the installer. This very well may be on your system already (it is the new installer used across all the windows platforms), but to play it safe we will try and install it anyway.

  1. Double click on "My Computer"
  2. Double click the icon for the CDRom drive where you have inserted the supplied CD.
  3. Double click the "ActiveStatePerl" folder.
  4. Double click the "98installer" folder. (I have included the NT version of the installer on the CD as well, but this is off the happy path so you are on your own. Windows 2000 and Windows ME already have the installer installed.)
  5. Double click the "InstMSI" icon.
  6. Use all the default answers to questions, reboot if so instructed

Now we can actually install Perl.

  1. Double click on "My Computer"
  2. Double click the icon for the CDRom drive where you have inserted the supplied CD.
  3. Double click the "ActiveStatePerl" folder.
  4. Double click the "ActivePerl..." icon. Note the full name changes with the version, but always starts with "ActivePerl".
  5. Accept all the defaults (next, accept, next, next, next, next, install, finish).
  6. Reboot if so instructed.

Finally, we can test our installation.

  1. Click on Start-> Programs -> MS-Dos Prompt.
  2. At prompt, type "perl -v" and hit return.
  3. You should see 10 lines or so of version messages and copyright information.
  4. If this fails, you most likely need to add the location of the perl executable file to the "PATH" entry in your C:\AUTOEXEC.BAT file. The install does this for you, but windows is easily confused and it does not always have the desired effect, I have seen it fail occasionally. The fix for this can come in a lot of different forms, depending on what junk already exists in your C:\AUTOEXEC.BAT file. If there is already a PATH command in the file, just add ;C:\PERL\BIN to whatever is on that line already, this is the safest approach. Alternately, simply add SET PATH=C:\PERL\BIN;%PATH% as a new last line after the last PATH command in the file. If you are not familiar with this, get somebody who knows DOS to help you add it, it's not hard, you might even be able to guess it. This is windows, so you will of course have to reboot for the changes to take effect.

Congratulations! You have installed Perl on your PC, the Duct Tape of the internet. Note that Perl is a full functioned programming language, and can be used for all sorts of tasks, not just CGI. But of course, that would be off the happy path...

Developing in Perl on DOS/Windows

At the risk of giving away my personal biases, lets just say that the Windows development environment has weak command line capabilities, and this is going to cause you some pretty major heartache relative to developing on a Unix style system.

I have nothing against graphical user interfaces... I am using one as I type this... but I believe that for development, an operating system without a quality command line environment is a fundamentally flawed operating system. Many things are easier with a GUI. Some things are not.

The MSDOS command interpreter embodies some unfortunate design decisions. In particular, it is impossible (near as I can figure, and I looked pretty hard) to get native support for either capturing the standard error messages to a file, or for scrolling backwards on the MSDOS window after a program has run. This can make debugging very difficult.

If you get a lot of errors when you try to run your program, you can't see the first ones (which are the most important ones, as they are likely the root of your problem).

Further, there seems to be some internal architectural problems with windows that confuse any tool that tries to wrap around normal program execution, and causes problems reading from standard input any time you are capturing standard error.

Historically, we have tried a number of solutions to this, all pretty painfull. The real solution is to use an operating system with a well thought out command line environment (like Unix), but that is not an option Windows.

Or is it? There has been a pretty innovative group of developers at a small company called Cygnus Solutions that spent quite a bit of time porting Unix tools over to run on MSDos based platforms. This was always a usefull collection of tools, and in the five years I have been following them and using their tools, they have been getting better and better.

They were recently bought out by RedHat, and the latest release of the cygwin toolkit is simply amazing. It is the perfect solution to our problem, and allows us to use much of the powerfull Unix style command line tools within a windows environment.

Installing the Cygnus Toolkit

  1. Double click "My Computer"
  2. Double click whatever icon is for your CDRom Drive (likely D:)
  3. Double click the "Cygnus" folder.
  4. Double click the first "Setup" icon in the folder (the one with the green and black icon).
  5. Follow the default prompts... next, install from local directory, next, next, next (wait forever) next.
  6. Double click on your freshly installed "Bash" icon on your desktop.
  7. Type "notepad .profile". We are setting up a set of commands to be executed each time a new window is brought up. Enter the following into the file and save and exit.
    alias goapache='cd /cygdrive/c/Program\ Files/Apache\ Group/Apache/'
    alias emacs='xemacs'
    
    export PATH=$PATH:/cygdrive/c/Program\ Files/XEmacs/XEmacs-21.4.5/i586-pc-win32/
    
    
  8. Cygnus actually installed its own version of Perl, which would probably do everything fine, but is tweaked for exclusively the cygwin environment. The Active State Perl we installed works for both the Windows and the DOS environment. To make sure we don't run different versions of Perl between manual debugging and our CGI implementation, lets move the Cygnus perl out of the way for now. Type the following at the bash window prompt:
    mv /usr/bin/perl.exe /usr/bin/perl.cygnus.exe
    
  9. Type exit to close the bash window. Bringing up a new bash window will make your changes take effect. Note you did NOT have to reboot (welcome to Unix).
  10. Now lets create a shortcut to another part of the Cygnus toolkit that will allow us to (gasp!) scroll backwards within a window and review the output of a program.
  11. Right click on an empty part of the windows desktop.
  12. Select new -> shortcut
  13. Enter the following for the command line (carefully... Welcome to Unix)
    C:\cygwin\bin\bash.exe -c '/usr/bin/rxvt -background black -foreground white -geometry 80x30 -loginShell'
    
  14. Name it xterm.
  15. Double click it to test. In the window that comes up, type goapache and hit return, followed by pwd . You should see /cygdrive/c/Program Files/Apache Group/Apache or something similiar.

Installing XEmacs

  1. No good command line environment is complete without a really powerfull editor, and Notepad ain't it.
  2. Double click on "My Computer", double click on whatever icon is for your CDRom (probably D:), and double click on the emacs folder.
  3. Double click "setup".
  4. Accept the defaults... next, install from local directory, next, next, next, finish.
  5. You can bring emacs up from the windows start menu, or by bringing up your xterm or bash window and typing emacs or xemacs .

  6. Return to Index