Perl, also Practical Extraction and Report Language (a backronym, see below)
dynamic procedural programming language designed by Larry Wall and first
released in 1987. Perl borrows features from C, shell scripting (sh), awk, sed,
Lisp, and, to a lesser extent, many other programming languages. The language is
intended to be practical (easy to use, efficient, complete) rather than
beautiful (tiny, elegant, minimal). Its major features are that it's easy to
use, supports both procedural and object-oriented (OO) programming, has powerful
built-in support for text processing, and has a large collection of third-party
The overall structure of Perl derives broadly from the programming
language C. Perl is a procedural programming language, with variables,
expressions, assignment statements, brace-delimited code blocks, control
structures, and subroutines.
Perl also takes features from shell programming. All variables are
marked with leading sigils. Sigils unambiguously identify variable
names, allowing Perl to have a rich syntax. Importantly, sigils allow
variables to be interpolated directly into strings. Like the Unix
shells, Perl has many built-in functions for common tasks, like sorting,
and for accessing system facilities.
Perl takes lists from Lisp, associative arrays from awk, and regular
expressions from sed. These simplify and facilitate all manner of
parsing, text handling, and data management tasks.
In Perl 5, features were added that support complex data structures,
first-class functions (i.e. closures as values), and an object-oriented
programming model. These include references, packages, and class-based
method dispatch. Perl 5 also saw the introduction of lexically scoped
variables, which make it easier to write robust code, and modules, which
make it practical to write and distribute libraries of Perl code.
All versions of Perl do automatic data typing and memory management.
The interpreter knows the type and storage requirements of every data
object in the program; it allocates and frees storage for them as
necessary. Legal type conversions are done automatically at run time;
illegal type conversions are fatal errors.
Perl has many and varied applications.
It has been used since the early days of the Web to write CGI
scripts, and is an integral component of the popular LAMP (Linux /
Apache / MySQL / Perl, PHP, and Python) platform for web development.
Large projects written in Perl include Slash, early implementations of
PHP, and UseModWiki, the wiki software used in Wikipedia until 2002.
It's known as one of "the three Ps" (Perl, Python, and PHP),
which are the most popular server-side, open source scripting languages
for the Web, though open source Java and C# implementations as well as
Ruby have grown popular in recent years.
Perl is often used as a "glue language", tying together
systems and interfaces that were not specifically designed to
interoperate. Systems administrators use Perl as an all-purpose tool;
short Perl programs can be entered and run on a single command line.
Perl is widely used in finance and bioinformatics, where it is valued
for rapid application development, ability to handle large data sets,
and the availability of many standard and third-party modules.
Perl is implemented as a core interpreter, written in C, together
with a large collection of modules, written in Perl and C. The source
distribution is, as of 2005, 12 MB when packaged in a tar file and
compressed. The interpreter is 150,000 lines of C code and compiles to a
1 MB executable on typical machine architectures. Alternatively, the
interpreter can be compiled to a link library and embedded in other
programs. There are nearly 500 modules in the distribution, comprising
200,000 lines of Perl and an additional 350,000 lines of C code. Much of
the C code in the modules consists of character encoding tables.
The interpreter has an object-oriented architecture. All of the
elements of the Perl languagescalars, arrays, hashes, coderefs, file
handlesare represented in the interpreter by C structs. Operations on
these structs are defined by a large collection of macros, typedefs and
functions; these constitute the Perl C API. The Perl API can be
bewildering to the uninitiated, but its entry points follow a consistent
naming scheme, which provides guidance to those who use it.
The execution of a Perl program divides broadly into two phases:
compile-time and run-time. At compile time, the interpreter parses the
program text into a syntax tree. At run time, it executes the program by
walking the tree. The text is parsed only once, and the syntax tree is
subject to optimization before it is executed, so the execution phase is
relatively efficient. Compile-time optimizations on the syntax tree
include constant folding, context propagation, and peephole
Perl is a dynamic language and has a context-sensitive grammar that
cannot be parsed by a straight Lex/Yacc lexer/parser combination.
Instead, it implements its own lexer, which coordinates with a modified
GNU bison parser to resolve ambiguities in the language. It is said that
"only perl can parse Perl", meaning that only the Perl
interpreter (perl) can parse the Perl language (Perl). The truth of this
is attested to by the persistent imperfections of other programs that
undertake to parse Perl, such as source code analyzers and
Maintenance of the Perl interpreter has become increasingly difficult
over the years. The code base has been in continuous development since
1994. The code has been optimized for performance at the expense of
simplicity, clarity, and strong internal interfaces. New features have
been added, yet virtually complete backward compatibility with earlier
versions is maintained. The size and complexity of the interpreter is a
barrier to developers who wish to work on it.
Perl is distributed with some 90,000 functional tests. These run as
part of the normal build process, and extensively exercise the
interpreter and its core modules. Perl developers rely on the functional
tests to ensure that changes to the interpreter do not introduce bugs;
conversely, Perl users who see the interpreter pass its functional tests
on their system can have a high degree of confidence that it is working
There is no written specification or standard for the Perl language,
and no plans to create one for the current version of Perl. There has
only ever been one implementation of the interpreter. That interpreter,
together with its functional tests, stands as a de facto specification
of the language.
Perl is free software, and is licensed under both the Artistic
License and the GNU General Public License. It is available for most
operating systems. It is particularly prevalent on Unix and Unix-like
systems (such as Linux, FreeBSD, and Mac OS X), and is growing in
popularity on Microsoft Windows systems.
Perl has been ported to over a hundred different platforms, and can,
with only six reported exceptions, be compiled from source on all
Unix-like, POSIX-compliant or otherwise Unix-compatible platforms,
including AmigaOS, BeOS, Cygwin, and Mac OS X (See ports). A special
port, MacPerl, is available for Mac OS Classic.
Perl can be compiled from source on Windows, however many Windows
installations lack a C compiler, so Windows users typically install a
binary distribution, such as ActivePerl or IndigoPerl. Users without a C
compiler are also limited to pure Perl modules if they wish to add to
the module library that comes with Perl. There's free software that can
enable these users to install C modules, however it tends to be poorly
documented, especially for beginners. [Source: Wikipedia]
Links to Perl
- The official Perl home page, run by O'Reilly. Contains documentation, news,
and links to a variety of resources.
Perl - Free Internet search engine for Perl developers. Search Web sites,
CPAN, and even inside Zip/Tar/GZip files.
- The Comprehensive Perl Archive Network, the gateway to all things Perl. The
canonical location for Perl code and modules.
- Perl 6 - The official site for the development of Perl 6, the next
generation of the Perl programming language.
: PERL Channel - Wide range of Perl scripts, programs and tutorials.
Network: Perl Weblog - Features links and commentary by a variety of
Perl Center - Current and past products, resources, and news on O'Reilly and
Associate's Perl involvement.
Cabal - Humorous profiles of Perl luminaries.
Perl Institute - Non-profit organization dedicated to making the incredibly
useful Perl language even more useful for everyone. Supports Perl creators,
developers, maintainers, and users. Recently disbanded, and is being
incorporated into the Perl Mongers.
Paraphernalia - By Mark-Jason Dominus. Perl Advanced Techniques Handbook
(drafts). Hints, articles, Perl modules, programs.
Quiz - Test your knowledge of Perl by answering 15 questions at basic,
intermediate or advanced level. Questions change every time.
University of Florida Perl Archive - Archives of comp.lang.perl;
documentation; scripts; and source code for perl.
Perl - General discussion of perl and issues relating to it, Perl news.