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

Functions

There are many functions predefined in Perl, too many to list here. Some are almost identical to standard utilities available on UNIX/Linux, such as chmod, mkdir, grep and sort. We present here a brief (and simplified) description of a set of standard Perl functions that we feel are particularly useful. For a full list, and a detailed explanation of each, you should consult the Perl web site at www.perl.com.

chdir changes the working directory to its (string) argument
do executes as a Perl program the file that is its (string) argument
eof returns true if its (filehandle) argument is at end of file
eval evaluates its argument as if it were a Perl program
exec executes the shell command that is its (string) argument
exit ends program immediately, exit status its argument
lc returns its (string) argument changed to lowercase
length returns the number of characters in its (string) argument
scalar returns the number of elements in its (array) argument
uc returns its (string) argument changed to uppercase

Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck