New Document
What is Perl?

Perl stands for "Practical Extraction and Report Language" or "Pathologically Eclectic Rubbish Lister." It is a powerful glue language useful for tying together the loose ends of computing life.

Perl is a programming language which can be used for a large variety of tasks. Both Perl interpreters and Perl documentation are freely available for Unix, MVS, VMS, MS/DOS, Macintosh, OS/2, Amiga, and other operating systems. (On Windows systems, Perl can be used in DOS command line mode.)

A typical simple use of Perl would be for extracting information from a text file and printing out a report or for converting a text file into another form. In fact, the name "Perl" was formed from the expression "Practical Extraction and Report Language". But Perl provides a large number of tools for quite complicated problems, including system administration tasks, which can often be programmed rather portably in Perl.


The following simple Perl program reads a text file consisting people's names like "John Smith", each on a line of its own, and it prints them out so that the first and second name have been swapped and separated with a comma (e.g. "Smith, John").

while(<>) {
  print "$_[1], $_[0]\n"; }


As you can see, Perl is compact - and somewhat cryptic, until you learn some basic notations. (There will be a rather similar example, which is annotated in some detail.)

Perl has become popular for programming handlers for World Wide Web forms and generally as glue and gateway between systems, databases, and users.

Perl is typically implemented as an interpreted (not compiled) language. Thus, the execution of a Perl program tends to use more CPU time than a corresponding C program, for instance. On the other hand, computers tend to get faster and faster, and writing something in Perl instead of C tends to save your time.

Programs written in Perl are often called Perl scripts, especially in the context of CGI programming, whereas the term the perl program refers to the system program named perl for executing Perl scripts. (What, confused already?)

If you have used Unix shell scripts or awk or sed or similar utilities for various purposes, you will find that you can normally use Perl for those and many other purposes, and the code tends to be more compact. And if you haven't used such utilities but have started thinking you might have need for them, then perlhaps what you really need to learn is Perl instead of all kinds of futilities.

Perl is relatively stable; the current major version, Perl 5, was released in 1994. Extensions to the language capabilities are mainly added though the construction of modules, written by different people and made available to other Perl programmers. For major general-purpose Perl applications, particularly CGI scripts and client or server applications, see CPAN Module documentation.

The following is the "Sales Pitch" by Doug Sheppard.




Creating, Storing and Running Perl Programs

The machines in the laboratories of the School of Computer Science have Perl installed under both UNIX and Windows-NT. For details, please consult the Technical Services Group's Website. To create a Perl program, you will need a text editor. In UNIX, you can use emacs, and in Windows-NT, you can use WordPad (you have to save the document in plain text format). In Windows-NT, you have to run your program in DOS-Shell.


Take the following text (using either emacs or WordPad) and put it into a file called


     print "Hi there!\n";




      Hi there!



Comments and Commands

After the header line: #!/usr/bin/perl there are either empty lines with no effect or commandlines or commentary lines. Everything from and behind a "#" up to the end of the line is comment and has no effect on the program. Commands start with the first non space charachter on a line and end with a ";". So one can continue a command over several lines and terminates it only with the semicolon.

History of Perl
Perl was first released December 1987. It was created by Larry Wall, then a systems administrator with JPL, to produce reports from multiple servers on a wide area network. Wall remains the "Benevolent Dictator" overseeing development of the language, which as it stands now represents the contribution of many, many people. Wall trained as a linguist before becoming a sysadmin, and that definitely had an affect on the development of the Perl language, particularly its tolerance of ambiguity and contextual interpretation.
Perl 5 was released in 1994. Perl 5 is still being actively maintained, is the most commonly used version of the language, and is what we will be looking at in this course. Perl 6 is in development, and has been for a long time. It is questionable as to whether version 6 will ever be as widely implemented as its predecessor.
In the early days of the web (mid-90s), Perl gained a lot of traction because web programming involves processing a lot of text (generally in the form of HTML). As specialized web-centric languages like PHP rose to prominence, Perl has become less important for web development, but it still has a place in that niche.
Uses of Perl
  • Tool for general system administration
  • Processing textual or numerical data
  • Database interconnectivity
  • Common Gateway Interface (CGI/Web) programming
  • Driving other programs! (FTP, Mail, WWW, OLE)
  • Why Perl?
    The question may arise as to why we are studying Perl rather than, say, C++ or Java. Languages are optimized for different things. Perl's roots in text processing & data manipulation make it highly relevant to library work, because a lot of what librarians work with is text. The availability of a number of library-related perl modules is another consideration, of which more in a moment.
    Also, Perl's C-like syntax has wide applicability for learning other languages. Anyone who knows Perl can pick up PHP, Python, Java more easily.

    Back to Top