Perl Course introduction
Perl Course Prerequisites
This course is designed for anyone who is already familiar with Perl and wants to understand how to use it specifically for Web-based applications.
You should already be able to program in Perl with basic familiarity using data types such as
- arrays, and
- associative arrays or hashes.
You should be able to use regular expressions; we will write several programs which will test your skill in pattern matching.
You should also know some basic HTML (HyperText Markup Language) since Perl programs will print to the screen in HTML.
This class will not teach you to program in Perl or to write HTML. The course will help you to sharpen your skills in both Perl and HTML, and describe ways to apply those tools to Web based CGI programming.
As a rule, Perl lets you do what you want, when you want to, and how you want to. Perl is far more concerned about letting you develop a solution that works than it is about slotting your chosen solution into a set of standards and a rigid structure. The core of any program are the variables used to hold changeable information. You change the contents of those variables using operators, regular expressions, and functions. Statements help to control the flow of your program and enable you to declare certain facts about the programs you are running. If you cannot find what you want using the
base Perl function set, you can make use of a number of modules, which export a list of variables and functions that provide additional information and operations. If you want to work in a structured format, modules also support objects, methods, and object classes. You can, of course, also make your own modules that use your own functions. We will have a quick look at some of the elements and components within Perl that will help when we start to look at these individual items in more detail.
Variables hold variable pieces of information—they are just storage containers for numbers, strings, and compound structures (lists of numbers and strings) that we
might want to change at some future point. Perl supports one basic variable type, the scalar. A scalar holds numbers and strings,
so we could rewrite the simple “Hello World” example at the beginning of this chapter as
$message = "Hello World\n";
In this example, we have assigned a literal to a variable called $message. When you assign a value to a variable, you are just populating that variable with some information.
A literal is a piece of static information—in this case it’s a string, but it could have been a number. By the way, when you assign information, you are assigning the value to the
right of the assignation operator (the = sign) to the lvalue on the left. The lvalue is the name given to a variable or structure that can hold information. Normally this is a
variable, but functions and objects are also types of lvalues. You will notice in the preceding example that the variable, $message, has a
character at the beginning. The dollar sign identifies the variable as
being a scalar. You always use a dollar sign when accessing a scalar value. The way to
remember a scalar is that the $ sign looks like an “s”, for scalar!
There are also some compound variable types—namely the array and the hash.
The array is a list of scalar variables—thus we can store a list of days using