56 HomeYamamoto and the Secret Admirers
Neal Stephenson

Misc

Perl
Perl (sometimes backronymed to Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister) is a programming language created by Larry Wall in 1987 that borrows features from C, sed, awk, shell scripting (sh), and (to a lesser extent) from many other programming languages as well. Though the name can be expanded as an acronym in more than one way (Pathologically Eclectic Rubbish Lister), it is normally spelt in normal mixed case when referring to the language, or lower case when referring to the interpreter. "Only perl properly parses Perl."

Rationale
Perl was designed to be a practical language to extract information from text files and generate reports. One of its mottos is There is more than one way to do it (TIMTOWTDI - pronounced 'Tim Toady'). Another is Perl: the Swiss Army Chainsaw of Programming Languages. One stated design goal is to make easy tasks easy and difficult tasks possible. Its versatility permits versions of many programming paradigms: procedural, functional, and object-oriented though purists object to Perl's as it is not a cleanly designed language. Perl has a powerful regular expression support built in directly to the syntax. Perl is often considered the archetypal scripting language and has been called the "glue that holds the web together", as it is one of the most popular CGI languages. Its function as a "glue language" can be described broadly as its ability to tie together different systems and data structures that were not designed to be tied together.

Perl is free software, available under the Artistic License and GPL. Perl is available for most operating systems but is particularly prevalent on Unix and Unix-like systems, and is growing in popularity on Microsoft Windows systems. As an example of Perl in action, until January 2002 the software running Wikipedia was a CGI script written in Perl. Another example is Slashdot, which runs on the Perl-based Slashcode software.

Implementation
A huge collection of freely usable perl modules, ranging from advanced mathematics to database connectivity, networking and more, can be downloaded from a network of sites called CPAN. Most or all of the software on CPAN is also available under either the Artistic License, the GPL, or both. CPAN.pm is also the name of the perl module that downloads and installs other perl modules from one of the CPAN mirror sites; such installations can be done with interactive prompts, or can be fully automated.

Although Perl has most of the ease of use features of an interpreted language, it does not strictly interpret and execute the source code one line at a time. Rather, perl first compiles an entire program to an intermediate byte code (much like Java's byte code), optimizing as it goes, and then executes that byte code. It is possible to compile a perl program to byte code to save the compilation step on later executions, though the "interpreter" is still needed to execute that code.

The current version 5.8 includes Unicode support. Perl 6 is currently being developed. It will run on Parrot, a virtual machine currently being developed as a possible multi-language target architecture.

Perl 6
Perl 6 will separate parsing and compilation and runtime, making the virtual machine more attractive to developers looking to port other languages to the architecture.

Parrot is the Perl 6 runtime, and can be programmed at a low level in Parrot assembly language. Parrot exists in a limited form as of June, 2003, and a small number of languages (Jako, Cola, Basic, Forth and a subset of Perl 6) exist simply to be 'compiled' down to Parrot assembly language opcodes.

Code samples
Some people humorously claim Perl stands for 'Pathologically Eclectic Rubbish Lister' due to the high use of meaningful punctuation characters in the language syntax, as may be seen in this example program to print a greeting:

 # A sample Perl program
 $_ = "Hello, world! The magic number is 234542354.\n";
 print;
 s/\d+/-1/;
 print;

and its output:

Hello, world! The magic number is 234542354.
Hello, world! The magic number is -1.

The fourth line of the example shows the use of a regular expression.

In common with C, obfuscated code competitions are an interesting feature of the Perl culture. Similar to obfuscated code but with a different purpose, Perl Poetry is the practice of writing poems that can actually be compiled by perl. This practice is fairly unique to Perl, due to the large number of regular English words used in the language. New poems can regularly be seen in http://www.perlmonks.org/index.pl?node=Perl%20Poetry.

External Links
http://dmoz.org/Computers/Programming/Languages/Perl/ - dmoz on Perl
http://www.perl.org - Perlmonger's info site
http://www.pm.org - Perlmonger's user group site
http://www.perlmonks.org - The Perl Monastery
http://activestate.com - ActiveState - Perl for Windows platforms
http://www.cpan.org/ - Comprehensive Perl Archive Network
http://dev.perl.org/perl6/ - Perl 6 development
http://www.parrotcode.org/ - Parrot virtual machine
http://www.perldoc.com/ - Perl POD documentation, rendered as HTML

This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Perl".

© Copyright 2002  ElectricInca. All rights reserved. | About us