The PERL Programming Language

Click below to go directly to a specific section: History | Significant Language Features | Areas of Application | Sample Programs Related Links | Printed References


PERL (Practical Extraction and Report Language) is a relatively new language. It was created in 1986 by Larry Wall. It has gone through a versions Perl, Perl4, and, the newly released Perl5.

New Features

Perl5 adds the following features: Regular expression enhancements, Arbitrarily nested data structures, Modularity and reusability, Object-oriented programming, Many usability enhancements, Simplified grammar, Lexical scoping, POSIX compliant, Package constructors and destructors, Multiple simultaneous DBM implementations, and Subroutine definitions may now be autoloaded.

Perl's Niche

Perl's strength lies in it's ability to interact with it's environment. It is a very powerful string manipulation language. It is able to open and manipulate many files from within the same program, with ease. It can manipulate UNIX shells, and issue commands to the system. All of these features make it a powerful Administrative tool that is in use on just about all major UNIX systems. It's popularity can be seen in the conversion of Perl to many home PC systems. It has been translated to function in MS-DOS, Windows, Windows 95, Macintosh DOS, and Amiga DOS, just to name a few.

New Directions for Perl5

Perl is starting to move towards it's C heritage by adding the ability to program using objects. It also is added the ability to be as structured, or unstructured, as you want it to be.
References used in preparing this summary are: Programming perl, written by Larry Wall and Randal Schwartz. It is an excellent source of information, and does a very good job of teaching you the intricacies of the language. The book is published by O'Reilly & Associates, a very good source for computer books. To visit their web page, just click here. And, finally, you can visit the Perl Archive, on the World Wide Web. It contains a lot of information that may be helpful to you in your quest to learn perl.  

Sample Programs

Here are some sample perl programs.

The first is a simple hello world program. When run, it will simply print out "Hello World!" onto the screen. Click here to see the source code, or click here to download the code.

Here is a simple program that reads in a file and returns the file with line numbers added.  Click here to see the source code, or click here to download the code.

This is a simple recursive program that does arithmetic with listrefs.  Click here to see the source code, or click here to download the code.

The next code is a little more complicated, and shows off perl's string handling power. It takes a file, specified by the user, either by being prompted by the program, or indicated on the command line, and removes all the spaces from it. The modified lines are written to a file with a .stp extention.

Example: The command line statement, file.txt, is the exact same thing as this prompt from the program, Please enter the name of the file to strip of spaces: file.txt. The program output would then be written to the file, file.stp.

This is just a sample of perl's string manipulation power. You can specify just about anything for the program to search and replace. A good use of this is creating HTML documents from text files. You can specify key words for the program to zero in on, and replace those words a hyper text code. Click here to see the source code, or click here to download the code.

Here is another example of perl's string manipulation power hower, this time we combine string manipulation with some file handling capabilities. This program demonstrates prompting the user for input, searching, and file manipulation.  It prompts the user for an input filename, an output filename, a search filename and a replacement string, and replaces all occurences of the search pattern with the replacement string while copying the input file to the output file.  Click here to see the source code, or click here to download the code.
This is a more advanced example that demonstrates user input, string manipulation, basic control statements, file manipulation, and the mail command. The program asks for a the user to enter their name.  If the user's name is Randal then the user is greeted otherwise, the user is asked to enter a secret word which must correspond to an entry in a pre-exising password file.  If the user fails to enter the correct password the the program sends mail to the programs's author notifying him of the users's failed attempt to login.  Click here to see the source code, or click here to download the code.

Related Links



Last modified: 12:18 AM on 11/14/1999  

This page has been accessed