Microsoft Store
 

Perl


 

Perl, also Practical Extraction and Report Language (a backronym, see below), is an interpreted procedural programming language designed by Larry Wall. Perl borrows features from C, shell scripting (sh), awk, sed, and (to a lesser extent) many other programming languages.

Overview

The perlintro(1) man page states:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

"Perl is a general-purpose programming language originally developed for text manipulation and now used for a wide range of tasks including system administration, web development, network programming, GUI development, and more.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

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 one of the world's most impressive collections of third-party modules."

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Language features

The overall structure of Perl derives broadly from 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. Perl programs are interpreted. All variables are marked with leading sigils. Sigils unambiguously identify variable names, thus 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.

Related Topics:
Shell - Interpreted - Sigil

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Perl takes associative arrays (known as 'hashes' in newer versions of perl) from awk and regular expressions from sed. These simplify and facilitate all manner of parsing, text handling, and data management tasks.

Related Topics:
Associative array - Awk - Regular expressions - Sed

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

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.

Related Topics:
Closures - Reference

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

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.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Applications

Perl has many applications. It has been used since the early days of the web to write CGI scripts, and is a component of the popular LAMP (Linux / Apache / MySQL / (Perl / PHP / Python)) platform for web development. Perl has been called "the glue that holds the web together". Large projects written in Perl include Slashdot and early implementations of PHP http://www.php.net/history and UseModWiki, the wiki software used in Wikipedia until 2002.

Related Topics:
CGI - LAMP - Linux - Apache - MySQL - PHP - Python - Slashdot - UseModWiki - Wiki - Wikipedia - 2002

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

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 3rd-party modules.

Related Topics:
Finance - Bioinformatics

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Implementation

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. Alternately, 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.

Related Topics:
As of 2005 - MB - Tar file - Compressed

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The interpreter has an object-oriented architecture. All the elements of the Perl language—scalars, arrays, hashes, coderefs, file handles—are 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 optimization.

Related Topics:
Constant folding - Peephole optimization

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Perl has a context-free grammar; however, it 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 can parse the Perl language. The truth of this is attested by the imperfections of other programs that undertake to parse Perl, such as source code analyzers and auto-indenters.

Related Topics:
Grammar - Lex - Yacc - GNU bison - Perl interpreter

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

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 backwards 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 properly.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

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.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Availability

Perl is free software, and may be distributed under either the Artistic License or 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.

Related Topics:
Free software - Artistic License - GNU General Public License - Operating systems - Unix - Unix-like - Linux - FreeBSD - Mac OS X - Microsoft Windows

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Perl has been ported to over a hundred different platforms. Perl 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. It 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. A custom port, MacPerl, is also available for Mac OS Classic. http://www.perl.com/CPAN/ports/

Related Topics:
Source - POSIX - AmigaOS - BeOS - Cygwin - Mac OS X - Windows - Mac OS Classic

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ Table of Content ~

Introduction
Overview
Language structure
Language design
Opinion
History
CPAN
Name
Fun with Perl
See also
External links
Books
References

 

 

~ What's Hot ~


~ Community ~

History Forum
Come and discuss about History, Civilizations, Historical Events and Figures
History Web-Ring
A community of sites, blogs and forums dedicated to History. Do not hesitate to submit your site.