Getting Started

Make sure that you have Perl on your system, if not grab a copy for the O/S that you have


Running a Perl program

In the Unix environment there are two ways to run a perl program first by supplying your perl source code as one of the arguments to the perl executable or by placing a line of code which tells the shell where to locate the perl interpreter (this must be the first line of code).

Using perl source code as an argument to the perl executable perl
Run the source without specifying the perl executable

Note: the below line must be the first line of code, you can find the location of perl by using the which command, also the perl program must have executable privileges


Obtain Perl version perl -v

In the windows world I have download a IDE environment (GUI) which allows me to edit the perl source code as well as run it, just make sure that the IE points to the Activestate perl executable

Executing in GUI
Executing in DOS prompt perl
Obtain Perl version perl -v

Sample Script

The first line tells the shell where to locate the interpreter (in this case the perl interpreter), the second line is a simple print statement.

Sample Code

print "Hello World!\n";

A statement is one task for the perl interpreter to perform, a perl program can be thought of as a collection of statements performed one at a time. The statement ends with a semi-colon as with the code above the print statement ends with a semi-colon.

The perl interpreter will ignore any whitespace unless it is in either single of double quotes.

You can use any editor (vi, emacs, notepad, IDE) to change perl source code, becareful if developing on windows and copying the code to a unix server, occasionally you end up with the DOS carriage return (^M) statements at the end of the code, use the 'Dos2Unix' command to remove these.

Perl User interaction

Perl has 3 ways to communicate with the user.

The default and other common options that they can use are


keyboard (default)
file to obtain data from

STDOUT monitor (default)
STDERR monitor (default)
console port
error logfile