CIW Course Revision Site


Getting Started with Perl

In a Nutshell - CIW Course Section 2, Part B1, Chapter 1

Perl Overview

Perl (Practical Extraction Report Language) is an interpreted programming language. Originally developed on the Unix platform, it's flexibility has made it widely popular for a number of tasks. The Perl interpreter is now available for most operating system platforms, and is commonly used by Web developers to create CGI scripts.

Perl is a flexible, loosely-typed language which brings the capabilities of C and shell scripting into a language that is easy to use with large data-handling capacity.

The Perl Interpreter

Because Perl is an interpreted language, it requires an interpreter to be available on the system that will run the scripts. Interpreted code is typically quicker to develop than compiled code, but tends to be slower to execute.

The first line in any Perl script will be the shebang line, which indicates the location of the Perl interpreter on the host system.

#!c:\perl\bin\perl.exe

I have looked at a number of Perl interpreters and found that Activestate ActivePerl seems to be the best, and one of the easiest to install. This is the interpreter that is discussed in the course notes.

A word of WARNING: When you download ActivePerl, be sure to save it to a local hard disk on the machine on which you intend to install it. It will not install from a mapped drive or share. This had me flummoxed for quite a while.

Print Function

Perl has many built-in functions and, perhaps, the most used is the print function. Perl is case-sensitive, so print is OK but PRINT and Print are not.

print ("Hello World\n");

The above line of code will display the ubiquitous "Hello World" message. The parentheses surrounding the argument are optional, but it is good coding convention to include them. The "\n" is the meta-character for a newline.

Design by Stephen

Certified Internet Webmaster

Page last Edited: 10 Nov 2011