Home
Perl Course



The-Brights.net

 

Calling Perl via PWS

You should now have Perl installed and Personal Web Server installed, and now you need to connect them together — you have to make your web server aware of the fact that when it gets URL's that call for perl scripts, it must run the perl script and serve the script's output. 

Without this special awareness, the server would handle perl scripts the same way it would any other file and it would just serve up the script file itself, which is not what you want at all.

To let the server know how to deal with perl scripts, you must specify the relationship in the Window's registry. Editing the registry is a potentially dangerous thing to do, especially for people not familiar with it, so be careful. I would be remiss not to remind you to back up your registry file first. But in the same breath, I have to admit I myself don't bother because there are regular backups done automatically by Windows each time you boot.

For Windows 95, 98, and Me users

If you downloaded my convenient PWS installation file in the PWS section, then you'll have a file that makes the required registry settings for you. Look in directory where you unzipped the archive for the file perl&pws.reg. When you find it, double click on it to run it. It'll ask if you're sure you want to add the information; say yes. It should then say the information was successfully entered.

You must reboot your computer for this change to take effect.

For Windows NT and 2000 Users

IIS users can click here for instructions on making the connection between Perl and IIS:

Important: Make sure you have rebooted before continuing.

The next thing to do is test the complete installation to make sure it works. By default, PWS allows scripts to run in the c:\scripts directory. Using Notepad, paste in the following text:

print "Content-Type: text/html\n\n";

print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Hello World</TITLE>\n";
print "</HEAD>\n";
print "<BODY>\n";
print "<H4>Hello World</H4>\n";
print "<P>\n";
print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
print "<P>";
print "<H5>Have a nice day</H5>\n";
print "</BODY>\n";
print "</HTML>\n"; 

Save this as hello.pl in the c:\scripts directory. IMPORTANT: Make sure when you save the file it gets saved as hello.pl and not hello.pl.txt. Notepad has an annoying habit of adding a .txt extension onto the end! If the file gets saved as hello.pl.txt, use Windows Explorer or DOS to rename the file as hello.pl. Then reopen it in Notepad and you'll be okay.

Once you have checked this, turn back to your browser again. Enter the URL: http://localhost/scripts/hello.pl and you should be looking at a web page that says "Hello World!" If so, break out the champagne, and have a little party. If not, check over everything I told you and see if you can find something wrong. Make sure you reboot after adding the contents of pws&perl.reg to the registry, or after tweaking the registry to adjust anything else.

Usually, if you have a problem, it's due to the setup within PWS. Right-click on the PWS icon in the lower right of your screen and select Properties, then Advanced. This is where you can get at the goodies in PWS. Select /Scripts and Edit Properties. Make sure the path in the "Directory" box agrees with where your scripts are.

If you get really stuck, email me, and I'll see if I can offer some helpful hints. When you email me, please try to mention these things:

  • your OS
  • running perl -v from the command line works.
  • your perl.exe file really is found in c:\perl\bin. If not, that's okay, but let me know where it really is.
  • you can see the welcome page from PWS at http://localhost.
  • you are using the c:\scripts directory for your files. If not, that's okay, but let me know where you'd like them to be.

So far, everyone that has contacted me has ultimately got it working, so there's hope for you too.

Before writing to me, check out the section on installation problems on my wiki. I am trying to build a database of problems and remedies there, so your problem may already be listed there.

Note as of Aug 2005: A lot of people have difficulty with configuring Microsoft's PWS or IIS. Most of the questions I get regarding installation are because of this. Let's face it - Microsoft's documentation on configuring these products is not good.

Nowadays, when someone writes to me for help with their PWS or IIS installation settings, I suggest they save themselves a lot of trouble and use a different webserver instead. It is free, and is well documented. You can find it at www.aprelium.com. Look for the Abyss Web Server X1. It works very well and is much easier to set up than PWS or IIS.

Now you have set the stage for your voyage into the world of CGI programming through perl. If you are setting out on your own, good luck. But surely you'd be better off following an introductory Perl course. So carry on here:

Introduction to Perl

____

Search this site here:

Google
www www.gossland.com

Questions? Feedback?

Email me your comments!

Like the course?

Please rate the site here