Perl Basics
Perl Basics has two main goals. First, it provides a
succinct summary of major Perl elements. Second, it provides
perspective and relates features to one another. Thus, you may think of
it as an extended and structured checklist, with commentary.
The discussion is oriented toward answering two questions:
- What are the things Perl provides you to work with?
- What can you do to those things?
The discussion includes six major sections:
- Variables and their Related Operators
- Control structures
- Functions
- Regular Expressions
- Input/Output
- System Operators
Perl provides three kinds of variables: scalars, arrays, and associative arrays. The discussion includes the designation of these three types and the basic operators provided by Perl for their manipulation.
Perl is an iterative language in which control flows from the
first statement in the program to the last statement unless something
interrupts. Some of the things that can interrupt this linear flow are
conditional branches and loop structures. Perl offers approximately a
dozen such constructs. Each of these basic constructs are described
along with examples illustrating their use.
Functions are a fundamental part of most programming languages. They
often behave like an operator, producing a change in the value of some
variable or returning a value that can be assigned to a variable. They
also control the flow of execution, transferring control from the point
of invocation to the function definition block and back. Thus, they
combine properties of the two preceding discussions. The discussion
will cover both the designation of functions and their invocation and
use.
Regular expressions are strings that can be recognized by a regular
grammar, a restricted type of context-free grammar. Basically, they are
strings that can be parsed left to right, without backtracking, and
requiring only exact symbol matching, matching of a symbol by a category
of symbols, or matching of a symbol by a specified number of sequential
occurrences of a symbol or category.
Perl provides a general mechanism for specifying regular expressions.
It also provides several operators that manipulate strings based upon
the evaluation of a regular expression.
The discussion will begin by describing the various mechanism for
specifying patterns and then discuss expression-based operators.
Perl provides basic I/O for both the standard input (keyboard) and
output (display) devices and for files in the UNIX file system. More
sophisticated I/O is provided through the UNIX DBM library. These
various I/O capabilities are discussed.
Perl offers a number of operators that mimic or call UNIX system
operators or analogous operators for other operating systems. The
discussion here will be cast in the context of UNIX and will assume
familiarity with basic UNIX facilities.
Perl system operators can be roughly divided into two large categories: file/directory operators and process operators. Both types are discussed.
Done
ReplyDelete