Learn Perl - An Introduction to Perl Programming
By Philip C. Paradis
Table of Contents
Welcome to my beginner's tutorial on programming in Perl! If you're still reading this, you probably have at least a passing interest in computer programming, the Perl language, or web development. If this doesn't describe you, you're probably looking for something else. If you're a seasoned Perl developer, or you're looking for advanced Perl recipes to solve problems like world hunger, this tutorial probably won't interest you. If, however, you're a fairly computer-savvy individual looking for a basic introduction to Perl and programming in general, read on.
Since you're still here, let's begin. Perl is a computer programming language; the name stands for "Practical Extraction and Reporting Language", originally created by Larry Wall. Like all programming languages, Perl allows you to create programs that tell a computer how to perform a particular set of tasks. The operating system you're using (Windows, Linux, MacOS, etc) was created by programmers, along with the web browser you're using to view this page. These are examples of rather large programming projects, well beyond the scope of this tutorial. My goal is to help you understand what programming languages are, and how to use Perl to get a start writing your own programs.
This material has been tested on a Linode Linux VPS (ClassHelper has been hosted on a Linode for years). If you don't have your own server, get a Linode today. As a disclaimer, I do work for Linode, but I was a very satisfied customer for over five years prior to joining the company.
What is a program, and how is one designed?
Essentially, a program can be viewed as a series of instructions that describe how a computer is supposed to perform a series of tasks. Programs are most commonly written in higher-level langauges like Perl, which allows programmers to easily express the steps taken to achieve a goal. The goal might be as simple as printing a single line of text on a computer screen, or as complex as analyzing a genetic database. No matter how big or small programs may be, they all follow the same basic set of rules.
Let's say you want to make a basic breakfast of eggs. You could break down the process into steps as follows:
A programmer's job is fairly simple: define the objective, identify the tools and materials required, and break down the process into a series of steps. When designing a program, many programmers will compose a list that resembles our breakfast example, a process known as "writing pseudo-code." Pseudo-code can be a list of steps like our example (plain English), or it can more closely resemble actual software code. The choice is yours.
Is Perl the right tool for the job?
Programming languages like Perl serve as an interface between the programmer and the "bare metal" of the computer. They allow programmers to design programs in languages that more closely resemble English than bare machine code (the ones and zeros of binary). This greatly accelerates software development, and allows other programmers to maintain the codebase in the future. Perl's syntax borrows heavily from other languages, such as C and Pascal. An important difference is the fact that most Perl programs are interpreted rather than compiled to native machine code before execution, which means your program is loaded by the Perl interpreter on your computer and compiled into memory before it runs. This means that some programs written in Perl will execute more slowly than compiled applications, depending on the program and computer environment in question. If raw speed is your objective (say, for scientific computing), Perl may not be the best tool for the job. If you need to write a web application that will run under the Apache web server with mod_perl, Perl can be a very good choice.
In our next section, we'll learn about what you'll need to get started with Perl programming.
Continue: System Requirements and Getting Perl