Computing Reviews

Beginning Perl programming :from novice to professional
Rothwell W., Apress,New York, NY,2019. 224 pp.Type:Book
Date Reviewed: 06/29/21

Perl 5 is a robust cross-platform language that has, as the author relates, been in use for more than two decades and become deeply embedded in the corporate information technology (IT) world. Most UNIX-based operating systems have a standard Perl derivative, which is installed by default or can be easily added through a package manager utility.

For Windows platforms, it is suggested that users install ActiveState Perl, Strawberry Perl, or DWIM Perl. I have some experience with the first two and can confirm that current versions are available; the other one belongs to a project that has apparently not been maintained for some time.

The author observes, in chapter 1, that a Perl program is most commonly invoked as a script. In a UNIX-based system, the first line of such a script can contain a shebang string, showing where the Perl interpreter can be found and the script can then be made executable. He also observes that Perl programs can be entered interactively in debug mode, and many of the examples are shown in line-by-line fashion, entered at debug prompts after an initial command like: “perl -d -e ‘1.’”

Chapter 1 concludes with some notes about Perl documentation using man and perldoc commands and online resources. The reader is invited to complete a small lab exercise, and his attempt can be compared with an example script that can be downloaded from the publisher’s website. This script is extended for lab exercises at the end of each subsequent chapter.

In chapter 2, “Scalar Variables,” readers can learn more than they ever really wanted to know about number formats, mathematical operations, and string operations. Did you know that “x” is a string operator that will repeat the preceding string the number of times shown in a subsequent integer?

Chapters 3 and 4, respectively, introduce array variables and associative array variables. Mechanisms for defining, accessing, and processing such variables are clearly explained in the examples given, and some basic flow control (if, for, foreach) statements are used in some of these. Flow control is covered in greater detail in chapter 5; note that the switch module has been removed from Perl core functions for versions 5.14 and above.

Chapter 6 (“Conditional Expressions”) illustrates the differences between string and numeric comparisons, and introduces some simple pattern matching concepts. Some file test conditions and filename considerations for different operating systems are discussed. I was surprised that File::Basename module was not mentioned in this context.

Chapters 7 and 8 are devoted to input and output procedures. The default (“$_”) variable and record-separator modifications are discussed. The reader is encouraged to use die and warn statements to handle file operation errors.

Pattern matching has always seemed to me like a dark science. I have to say that chapter 9 left me feeling a bit more comfortable. Clear explanations and examples show the effects of matching, substitution, and translation operators; the roles of the g and i modifiers are also shown. I’m still uneasy about regular expressions and metacharacters, but at least I now know where to look for examples.

There is a short chapter about Perl utilities (split, substr, index, rand, sleep) and another short chapter about files, directories, and process control. These are followed by a longer chapter, “Functions,” which provides some good examples of function structure and calling mechanisms.

The penultimate chapter, “Using Modules,” contains just five pages and covers only the Text::Wrap, diagnostics, and strict modules.

The subtitle of this book is from novice to professional. Novices who read it will gain a really good understanding of Perl statements and operations; however, they won’t have much of an idea of Perl common practices (like always including use strict and use warnings), and they won’t really know how to collect command-line options. I’d recommend looking at [1] if you can get a copy.


1)

Johnson, A. L. Elements of programming with Perl. Manning, Shelter Island, NY, 2000.

Reviewer:  G. K. Jenkins Review #: CR147296 (2111-0259)

Reproduction in whole or in part without permission is prohibited.   Copyright 2024 ComputingReviews.com™
Terms of Use
| Privacy Policy