Mike Gossland's Perl Tutorial Course for Windows

What's Perl | Task Examples | Running Perl | Variables | Flow Control | Simple Scripts

Chapter 1: Introduction

Running perl scripts

Before you can run Perl, you have to install it on your system. If you haven't done so already, go to the Perl installation page for more instructions. At this stage, you don't have to install a web server and you should leave that for a later session. Installing Perl should be quite quick and simple, so go ahead and get it in place. Make sure you reboot before continuing.

For the first part of this course, we'll be running perl scripts in a DOS window. This means we're going to be typing words in at the dos prompt. Yes indeed, a command line environment instead of a Windows GUI! This is good or bad, depending on your point of view. (I think it's good even though the dos prompt is not a shining example of a good shell.)

Once you've installed perl and rebooted into Windows, bring up a DOS window. It doesn't matter what directory you are in for now. Just type in:

perl -v

and you should get back a screenful of version information from perl. If you get a "bad command or filename" message, Perl isn't properly installed. See if you can fix it.

Running your first Perl script: Hello World!

Now it's time to feel like you're getting somewhere. You're going to write your first perl script. Go back to your DOS prompt and this time, make sure you're working in a directory where you can edit a file or two.

Use notepad or some simple text editor (not MS Word!) to create a file with this line in it. You can cut and paste it directly from here:

print "hello world\n";

Save the file as "hello.pl" and turn to your DOS session and type:

perl hello.pl

The screen should show

hello world

right underneath.

Congratulations, you've just run your first perl script!

Now you need to learn a bit more about the language so you can create something more interesting.