Getting Started

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

Unix www.perl.org
Windows www.activestate.com

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 hello_world.pl
Run the source without specifying the perl executable

hello_world.pl

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

#!/usr/local/bin/perl

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 http://open-perl-ide.sourceforge.net/
Executing in DOS prompt perl hello_world.pl
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

#!/usr/local/bin/perl
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

STDIN

keyboard (default)
file to obtain data from

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