Main index

Introducing UNIX and Linux


Perl

Overview
Introduction
      Why yet another utility?
      Beginning Perl
      Invoking Perl
      Documentation on perl
      Perl Scripts
Variables
Input and output
      Files and redirection
      Pipes
      The DATA filehandle
Fields
Control structures
Predefined Perl
      Functions
      Modules
Regular expressions
      Single character translation
      String editing
Perl and the Kernel
Quality code
When do I use Perl?
Summary
Exercises

Beginning Perl

We will assume that the previous chapters have made sense to you. Our goal is to identify the types of tasks for which the other tools you are now familiar with are inappropriate, and to show how to begin to code them in Perl. Our starting point will be processing a stream of characters, just as we did with Awk.

However, before we start, there is a fundamental difference between Perl and Awk. Whereas an Awk script assumes its data is naturally separated into records which themselves are subdivided into fields, a Perl program does not. Perl is a general purpose programming language, and although it can perform the same tasks as Awk (very easily, in fact) there are no constraints on its manner of use. Perl is not an "interactive shell". While the shell can be used to "talk to" the operating system in real time, Perl is not designed to. If the data you wish to process is not very well structured you should consider using Perl.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck