\chapter*{Preface\markboth{Preface}{}}
\pdfbookmark[0]{Preface}{preface}

If you are looking for a free Perl tutorial that is packed with %
everything you need to know to get started on Perl programming, look %
no further. Presenting before you is probably the most comprehensive %
Perl tutorial on the Web, the product of two years of diligence seeking %
reference from related books and Web sites. \\

Perl is a programming language that is offered at no cost. So wouldn't %
it be nice if you can also learn it at no cost? Packed with some background %
knowledge of programming in C++ and Visual Basic, when I started learning Perl %
several years ago, I couldn't even find one good online tutorial that covered %
at least the basics of the Perl language and was free. Most Perl tutorials %
I could find merely covered the very basic topics such as scalar/list assignment, %
operators and some flow control structures etc. On the other hand, %
although I have accumulated certain levels of experience in a number of programming %
languages, the official Perl manual pages are quite technical with whole pages %
of jargons that I was not very familiar with. As a result, the book 
\textit{\textbf{``Learning Perl''}} written by Larry Wall, the inventor %
of the Perl language, naturally became the only Perl textbook available. %
The O'Reilly Perl Series present the most authoritative and well-written %
resources on the subject written by the core developers of Perl. While you are %
strongly recommended to grab one copy of each if you have the money, they are not %
so cheap, though, and that's the motive behind my writing of this tutorial --- so that %
more people with no programming background can start learning this stupendous and %
powerful language in a more cost-effective way. \\

Although this tutorial covers a rather wide range of topics, similar to what you can %
find in some other Perl guidebooks, you are strongly encouraged to read those books %
too, since their paedagogies of teaching may suit you more. \\

Here are several features of this tutorial: \\

\begin{itemize}
\item {% 
As this is not a printed book, I will constantly add new materials to this tutorial %
as needed, thus enriching the content of this tutorial. Moreover, in order to help me %
improve the quality of this tutorial, it is crucial for you to forward me your comments %
and suggestions so that I can make further improvements to it.
}
\item {%
Earlier drafts of this tutorial were published in HTML format on my Web site.
In response to requests made from several visitors, this tutorial has been made available in PDF format %
for download. I hope this will help those who are charged on time basis for connecting %
to the Internet. This tutorial is typeset in \LaTeX, a renowned document typesetting system 
that has been widely used in the academic community on Unix-compatible systems (although it
is available on nearly any operating systems you can think of). The HTML version has been 
discontinued, until a solution can be found which allows both versions to be generated from 
the same source base. 
}
\item {%
You will find a list of Web links and references to book chapters after each chapter where applicable which %
contains additional materials that ambitious learners will find helpful to further your %
understanding of the subject.
}
\item {%
Throughout the text there would be many examples. In this tutorial, you will find two types %
of examples --- \textbf{examples} and \textbf{illustrations}. Illustrations are intended to %
demonstrate a particular concept just mentioned, and are shorter in general. You will find them
embedded inline throughout the tutorial. On the other hand, %
examples are more functional and resemble practical scripts, and are usually simplified %
versions of such. They usually demonstrate how different parts of a script can work together %
to realize the desired functionalities or consolidate some important concepts learned in a particular %
chapter.}
\item {%
If applicable, there will be some exercises in the form of concept consolidation questions as well %
as programming exercises at the end of each chapter to give readers chances to test how much they %
understand the materials learned from this tutorial and apply their knowledge through practice.%
}
\end{itemize}

This is the First Edition of the Perl 5 Tutorial. It primarily focuses on fundamental Perl programming
knowledge that any Perl programmer should be familiar with. I start with some basic ideas behind
computer programming in general, and then move on to basic Perl programming with elementary topics such as 
operators and simple data structures. The chapter on scoping and subroutines is the gateway to subsequent, but more
advanced topics such as references and object-oriented programming. The remaining chapters are rather
assorted in topic, covering the use of filehandles, file I/O and regular expressions in detail.
There is also a dedicated chapter on error handling which discusses facilities that you can use to locate logical errors and enhance program security.
The final chapter on CGI programming builds on knowledge covered in all earlier chapters. Readers
will learn how to write a Perl program that can be used for dynamic scripting on the World Wide Web.
However short, the main text already embraces the most important fundamental subjects in the Perl 
programming language. In the appendices, instructions are given on acquiring and installing Perl
modules, setting up a basic but functional CGI-enabled Web server for script testing, and there is a voluminous
coverage of Unix fundamentals. As much of Perl is based on Unix concepts, I believe a brief understanding of this
operating system is beneficial to Perl programmers. An appendix is also prepared to give my readers an idea
of the internal structure of general hashes. While authoring of this tutorial cannot proceed indefinitely,
topics that were planned but cannot be included in this edition subject to time constraints are deferred to 
the Second Edition. A list of these topics appear at the end of this document for your reference. \\

In the second release candidate of this tutorial I made an audacious attempt of adding into it two topics
that are rarely discussed in most Perl literature. The first is the \mono{Error} CPAN module for exception
handling. The second attempt, which is an even more audacious one, is an introduction of the finite-state
automaton (FSA) for construction of complex regular expressions for pattern matching. While FSA is a fundamental
topic in Computer Science (CS) studies, this is seldom mentioned outside the CS circle. Although there is
a high degree of correspondence between regular expressions and FSA, this may not be at all obvious to a
reader without relevant background, despite I have avoided rigorous treatment of the topic and tried to 
explain it in a manner that would be more easily communicable to fellow readers. I would like to emphasize
this topic is not essential in Perl programming, and I only intend to use it as a tool to formulate better
patterns. Feel free to skip it if that is not comfortable to you and I require your feedback of whether 
these topics can help you as I originally intended. \\

It is important for me to reiterate that this document is not intended to be a substitute for the 
official Perl manual pages (aka \textit{man pages}) and other official Perl literature. In fact, it 
is the set of manual pages that covers the Perl language in sufficiently fine detail, and it will be 
the most important set of document after you have accumulated certain level of knowledge and programming 
experience. The Perl man pages are written in the most concise and correct technical parlance, and as a 
result they are not very suitable for new programmers to understand. The primary objective of this tutorial 
is to bridge the gap so as to supplement readers with sufficient knowledge to understand the man pages. 
Therefore, this tutorial presents a different perspective compared with some other Perl guidebooks available at your local 
bookstores from the mainstream computer book publishers. With a Computer Science background, I intend to
go more in-depth into the principles which are central to the study of programming languages in general.
Apart from describing the syntax and language features of Perl, I also tried to draw together the classical
programming language design theories and explained how they are applied in Perl. With this knowledge, it is hoped
that readers can better understand the jargons presented in manual pages and the principles behind. Perl is attributed
by some as a very cryptic language and is difficult to learn. However, those who are knowledgeable about programming
language design principles would agree Perl implements a very rich set of language features, and therefore is an ideal
language for students to experiment with different programming language design principles taught in class in action.
I do hope that after you have finished reading this tutorial you will be able to explore the Perl horizons 
on your own with confidence and experience the exciting possibilities associated with the language more easily. 
\textit{``To help you learn how to learn''} has always been the chief methodology followed in this tutorial. \\

Time flies. Today when I am revising this preface, which was actually written before I made my initial preview 
release in late 2001 according to the timestamp, I am aghast to find that it has already been nearly two years
since I started writing it. Indeed, a lot of things have changed in two years. Several Perl manpages written in
tutorial-style have been included into the core distribution, which are written in a more gentle way targeted at beginners. There
are also more Perl resources online today than there were two years ago. However, I believe through preparing this
tutorial I have also learnt a lot in the process. Despite I started this project two years ago, a major part of
the text was actually written in a window of 3 months. As a result, many parts of the tutorial were unfortunately 
completed in a hasty manner. However, through constant refinement and rewriting of certain parts of the tutorial,
I believe the Second Edition will be more well-organized and coherent, while more advanced topics can be accommodated
as more ample time is available. \\ 

At last, thank you very much for choosing this tutorial. Welcome to the exciting world of Perl programming! \\

\begin{flushright}
Bernard Chan\\
\textsl{in Hong Kong, China} \\
15\super{th} September, 2003
\end{flushright}

%{\Large\sf\textbf{Save the trees. Read, don't print.}}
%\vspace{2cm}
\clearpage

\section*{Typographical Conventions}

\p{Although care has been taken towards establishing a consistent typographical convention throughout 
this tutorial, considering this is the first time I try to publish in \LaTeX, slight deviations may
be found in certain parts of this document. Here I put down the convention to which I tried to adhere:}

\p{Elements in programming languages are typeset in \mono{monospace font}.}

\p{Important terms are typeset in \textbf{bold}.}

\p{Profound sayings or quotes are typeset in \textit{italic}.}

\p{In source code listings, very long lines are broken into several lines. \P\ is placed 
wherever a line break occurs.}

\vspace{1.5cm} 

\section*{Release History}

\vspace{1cm} 

\begin{tabular}{p{4.2cm}l}
30\super{th} August, 2003	&	First Edition, Release Candidate 1 \\ [0.2cm]
15\super{th} September, 2003	&	First Edition, Release Candidate 2 \\ [0.2cm]
01\super{st} October, 2003	&	First Edition, Release Candidate 3 \\ [0.2cm]
31\super{st} December, 2003	&	First Edition \\
\end{tabular}

\vspace{3cm}

\section*{About The Author}

\vspace{1cm} 

\textbf{Bernard Chan} was born and raised in Hong Kong, China. He received his Bachelor's Degree in Computer
Engineering from the University of Hong Kong. His major interests in the field include information system
security, networking and Web technologies. He carries a long-term career objective of becoming an avid technical writer
in the area of programming. His most notable publication is the \textit{Perl 5 Tutorial}.
