4.1 Introduction


The fourth letter in the LAMP acronym stands for Perl (along with the other Ps). Although you don't have to understand any Perl to build a web site, it helps (Python and PHP work too). In many examples that follow throughout this book, we use the basics of Perl extensively.

The purpose of this chapter is to familiarize the Perl novice with the basics. If you already know a C-like language, much of this will be familiar. If not, this chapter should introduce you to the concepts we use throughout the rest of the book. If you already know Perl, good for you! But this will be a rehash ”feel free to move on.

Perl has become a popular all-purpose programming language because of its power and ease of use. Once you have mastered the language rules, you can do a lot with a little. One of the mottoes of Perl is Perl Makes Easy Tasks Easy and Hard Tasks Possible . Another is There's More Than One Way To Do It ”TMTOWTDI, pronounced "Tim-Toe-Di."

Perl originated as a text processing language. [1] Larry Wall, the creator, needed a language to manage and manipulate a database of text files. He designed Perl to be a language with built-in text processing by incorporating regular expressions and providing a number of text processing functions. There are and have been many other text processing languages: REXX, awk, sed, etc. But Perl has struck a chord, and not only with Open Source developers ”it has been ported to all major operating systems and many minor ones. It has been (lovingly) referred to as the duct tape that holds the Internet together. One of the happy results of the spread of Perl is its portability; if created properly, Perl scripts will run on many operating systems with only minor changes, if any.

[1] There are histories of Perl at www.perl.org/press/history.html and history.perl.org.

The name Perl is an uncapitalized acronym for Practical Extraction and Report Language, or Pathologically Eclectic Rubbish Lister ” TMTOWTDI.

As it evolved, Perl grew (some would say mutated) from a text processing language into a powerful, multipurpose object-oriented programming language used to solve all kinds of real-world problems: system administration, network programming, database management, and CGI programming.

Perl's syntax is C-like. [2] Its operators, constructs, and lexical conventions are similar to those of C. However, some of the language rules, especially regular expressions, can be a bit overwhelming at first. It's common for eyes to cross a bit when looking at one of the ubiquitous strings of punctuation representing a regular expression: / ^ (?:To:)\s*(\S*)$/ ”not comic strip expletives, but the coin of the Perl realm. However, by concentrating on the basic rules, you can quickly learn to use the language to solve real problems ”this is the beauty of the language. Of course, then you are suckered in and have become yet another Perl acolyte.

[2] Collectively, the trinity of C, C++, and Java are referred to as C-like languages.

We give only a basic overview here; the Camel Book [Wall+ 00] is the bible for Perl. Perl is the big, fat, top-of-the-line Swiss Army knife . We don't talk about all the nifty gadgets, only the major functionality. We can't teach you programming in this short chapter, so this is a high-level introduction. Again, we assume you know the basics of programming: variables , flow constructs ( if statements, while loops ), functions, reading from and writing to files, and so on.



Open Source Development with Lamp
Open Source Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP
ISBN: 020177061X
EAN: 2147483647
Year: 2002
Pages: 136

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net