Perl - the Programming Language Content from the guide to life, the universe and everything

Perl - the Programming Language

0 Conversations

Perl is a programming language. It has many uses, but a few examples are:

  • Dynamic web1 pages;
  • 'Quick and dirty' programming of administrative tasks;
  • Full-blown platform-independent graphical applications.

Perl started life as a scripting language under Unix. That origin shaped the language in some significant ways. In a scripting language, you want to just type code and run it, so Perl is interpreted rather than compiled. You don't want to worry about declaring variables, so Perl doesn't require that. Admin tasks tend to call for text manipulation, so Perl excels in that.

Possibly the most striking feature of Perl is its users' strong community spirit, perhaps more than in any other language. They share code via CPAN and some of the most respected authorities in the language will answer your questions in Perl Monks.

Many Perl users are hackers2. Hackers program for fun, and for the intellectual challenge. Perl hackery includes obfuscation, Perl golf and JAPHs, all of which are discussed below.

The Language

Like most modern programming languages, Perl builds on the experience of earlier languages. About Perl lists C, awk, sed, sh, and BASIC as major influences. As its creator, Larry Wall, says, Perl came out of his 'laziness, impatience and hubris'. His intention was to 'make easy things easy and hard things possible'. In the same interview, he explains the origin of the name. He wanted 'a short name with positive connotations'. Both Practical Extraction and Report Language and Pathologically Eclectic Rubbish Lister are backronyms.

That Perl caught on at all is evidence that Larry3 created a language that was better than its predecessors, at least some of the time. That other languages, notably Ruby, have emerged since suggests Perl isn't perfect.

A common Perl slogan is 'There's More Than One Way To Do It' (TMTOWTDI). Perl's versatility means that users coming to it from different languages can often find a familiar Perl idiom. It does contribute towards Perl's reputation for being difficult to read, and contrasts with, for example, Python's much more minimalist philosophy.

A common feature of many Perl programs is the use of regular expressions. These allow a Perl program to search through a string for sub-strings that match a specific pattern, and optionally replace those sub-strings. Regexes are not exclusive to Perl, but Perl is often used in applications where they are useful.



If you access a website that is more than a collection of static pages, if it has a log-in facility, if pages change in response to user inputs, then there is some software running on the server to make that happen. There's a good chance that software is written in Perl. Traditionally C and C++ (for example, DNA, which drives h2g2) were popular alternatives to Perl; more recently Java, VBScript and Ruby have emerged. This list is not exhaustive.

Traditionally, dynamic web pages were served using the Common Gateway Interface (CGI) protocol. The user's browser would request a page from a web server, which would start up a CGI program (written in Perl or whatever), which would generate the page and pass it back to the web server, which would return it to the user. This means that a separate instance of the CGI program would be generated for every page request. A much more efficient way of doing things is to build the Perl interpreter into the web server itself. Mod_perl is an implementation of Perl that can be incorporated into the popular Apache web server. A third option, Embperl, allows Perl to be embedded within an HTML document, in much the same way as PHP.


You can get some idea of the range of applications to which Perl has been put by browsing the Comprehensive Perl Archive Network (CPAN). Although CPAN includes complete programs (and Perl itself), the real wealth is in the variety of modules that you can incorporate into your own programs. Just a few examples are:

Perl Monks

Many Perl programmers subscribe to Perl Monks, an online community powered by the Everything engine (written in Perl, of course).

Perl Monks allows people (including non-members) to post entries (known as 'nodes') in any of several 'sections'. The site is moderated by an experience system. Members can vote for or against nodes. Members gain 'eXperience Points' (XP) and move up through a series of levels, mainly by posting nodes that attract large numbers of 'upvotes'.

Levels in Perl Monks are given whimsically ecclesiastical names: 1=initiate, 2=novice, etc. With increasing level, monks gain in their daily allowance of votes and, from level 9=friar, can become involved in moderation, including 'considering' nodes for 'reaping' or removal. Moderation by voting and XP appears to work very well and reaping is rarely necessary.

Many Perl Monks give generously of their time in support of others, and it is perhaps invidious to name names. But the list of 'Saints' who lead the XP rankings is headed by vroom (Tim Vroom, who created Perl Monks), followed by Merlyn (Randal Schwartz, co-author of Learning Perl). Larry Wall himself goes by the name of TimToady.

Just for fun


Obfuscation, according to AskOxford, is to 'make unclear or unintelligible'. Obfuscation is hiding the code in another shape or form; obscuring the real action of the code in one way or more. TMTOWTDI, together with Perl's relatively terse syntax, means that Perl programmers can write fiendishly obfuscated code, and other Perl programmers enjoy the challenge of unravelling these 'obfus'. Perl Monks has a whole section devoted to obfuscated code. One master of the obfu is Erudil. His camel code obfu, based on the cover of Programming Perl is a fine example.


CPAN contains a great many modules that have been created mainly for the intellectual challenge. TheDamian (Damian Conway, author of Perl Best Practices) is responsible for some of the most extraordinary examples. His Lingua::Romana::Perligata allows the user to write Perl that looks uncannily like Latin, not only in the words but also in the syntax. Plus his Acme::Bleach allows the user to write Perl that looks uncannily like nothing at all!

Perl golf

Perl golf, as the name (perhaps) suggests, is writing code to meet a specified requirement in as few (key-) strokes as possible. Frequent competitions are organised.


A JAPH is a perl program that generates the phrase 'Just another Perl hacker'. The earliest JAPHs were by Randal Schwartz. JAPHs can be seen as a special case of obfuscation, sometimes combined with Perl golf as some Perl hackers (but not all) strive to fit their JAPHs within the conventional limit of four lines of 80 characters4 for email and Usenet signatures. 'Abigail', a respected authority on the subject, has written a 'presentation' on JAPHs5. As with all things Perlish, a variety of examples of JAPHs can be found at CPAN.

Further reading

  1. Perlintro from the Perl documentation.
  2. Perl, the first postmodern computer language by Larry Wall.
1There are many webs (eg, on intranets), but only one World Wide Web (on the Internet). Capitalisation reflects that distinction.2'Hacker' is a word that, like 'salt', 'sugar' and 'acceleration', has a much more specific meaning in popular usage than among the specialists who use it every day - see Hackers and Crackers.3Presumptuous, but common usage suggests that Larry is that kind of guy.4Authorities differ as to whether the limit is 'no more than 80' or 'fewer than 80'.5h2g2 rules forbid linking to this as the URL 'contains a word which other users may find offensive'.

Bookmark on your Personal Space

Conversations About This Entry

There are no Conversations for this Entry

Edited Entry


Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry

Categorised In:

Written by

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more