programming language, started by Larry Wall
in 1987 and developed as an open source
project. It has an eclectic heritage, deriving from the ubiquitous C
programming language and to a lesser extent from sed
, various Unix shell
, and at least a dozen other tools and languages. Originally developed for Unix
, it is now available for many platforms
Perl's elaborate support for regular expression
matching and substitution has made it the language of choice for tasks involving string manipulation, whether for text or binary data. It is particularly popular for writing CGI scripts.
The language's highly flexible syntax and concise regular expression operators, make densely written Perl code indecipherable to the uninitiated. The syntax is, however, really quite simple and powerful and, once the basics have been mastered, a joy to write.
Perl's only primitive
data type is the "scalar", which can hold a number, a string, the undefined value, or a typed reference. Perl's aggregate
data types are arrays
, which are ordered lists of scalars
indexed by natural numbers
, and hashes (or "associative arrays") which are unordered lists of scalars indexed by strings. A reference can point to a scalar, array, hash, function
, or filehandle. Objects
are implemented as references "blessed
" with a class
name. Strings in Perl are eight-bit clean
, including nulls
, and so can contain binary data
Unlike C but like most Lisp dialects, Perl internally and dynamically handles all memory allocation, garbage collection
, and type coercion
Perl supports closures
, recursive functions, symbols
with either lexical scope
or dynamic scope
, nested data structures of arbitrary content and complexity (as lists or hashes of references), and packages (which can serve as classes, optionally inheriting methods
from one or more other classes). There is ongoing work on threads
, and backtracking
. Perl program files can contain embedded documentation in POD
(Plain Old Documentation), a simple markup language.
The normal Perl distribution contains documentation for the language, as well as over a hundred modules (program libraries). Hundreds more are available from The Comprehensive Perl Archive Network
. Modules are themselves generally written in Perl, but can be implemented as interfaces to code in other languages, typically compiled C.
The free availability of modules for almost any conceivable task, as well as the fact that Perl offers direct access to almost all system calls and places no arbitrary limits on data structure size or complexity, has led some to describe Perl, in a parody of a famous remark about lex
, as the "Swiss Army chainsaw" of programming.
The use of Perl has grown significantly since its adoption as the language of choice of many World-Wide Web
interfaces and libraries for Perl exist for several platforms
and Perl's speed and flexibility make it well suited for form processing and on-the-fly web page
Perl programs are generally stored as text source
files, which are compiled into virtual machine
code at run time; this, in combination with its rich variety of data types and its common use as a glue language, makes Perl somewhat hard to classify as either a "scripting language
" or an "applications language
" -- see Ousterhout's dichotomy
. Perl programs are usually called "Perl scripts", if only for historical reasons.
Version 5 was a major rewrite and enhancement of version 4, released sometime before November 1993. It added real data structures by way of "references", un-adorned subroutine
calls, and method inheritance
The spelling "Perl" is preferred over the older "PERL" (even though some explain the language's name as originating in the acronym for "Practical Extraction and Report Language"). The program that interprets/compiles Perl code is called "perl", typically "/usr/local/bin/perl" or "/usr/bin/perl".
Latest version: 5.005_03 stable, 5.005_62 in development, as of 1999-12-04.
newsgroups: news:comp.lang.perl.announce, news:comp.lang.perl.misc.
["Programming Perl", Larry Wall and Randal L. Schwartz, O'Reilly & Associates, Inc. Sebastopol, CA. ISBN 0-93715-64-1].
["Learning Perl" by Randal L. Schwartz, O'Reilly & Associates, Inc., Sebastopol, CA].