Mike Gossland’s Perl Tutorial Course for Windows

Calling Perl through the Web Server

You should now have Perl installed and a Web Server installed.

Telling the server how to handle perl scripts is the tricky part of the installation, so I hope you've had a try at it by now. Before proceeding to try out your own perl scripts, you should do your best to make sure your webserver has been configured to handle perl scripts correctly.

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

You'll have to locate the root directory for your webserver as well. This is the directory that is served up when you visit your local home page at http://localhost.

Quite often, the scripts directory is called cgi-bin and it is located under the root webserver directory.

From the scripts directory, open a text file for editing. Paste the following into it.

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>Your IP Address is ".$ENV{REMOTE_ADDR}."</p>\n";
print "<h5>Have a nice day</h5>\n";
print "</body>\n";
print "</html>\n";

Save this file as hello.pl in your designated scripts directory.

IMPORTANT: When you save the file make sure 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 verified this, turn back to your browser again. Enter the URL:


and you should be looking at a web page that says "Hello World!"

If so, have a little party. If not, check over everything I told you and see if you can find something wrong. Make sure you properly followed the instructions and tests for your web server configuration.

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 my introductory tutorial Perl course for Windows. So carry on here:

Introduction to Perl

Search this site or the web:

just this site the whole web

Questions? Feedback?

Email me your comments!