on 3 July 1999
After studying the O'Reilly Camel (that is, Larry Wall et al, Programming Perl, Second Edition) and doing a little website management with perl, I found the introductory textbook "Perl: The Programmer's Companion" by Nigel Chapman delightfully different from the many hardly investigated or poorly written IT publications in print.
Tom Christiansen, well-known Perl consultant from among the above altera, highly recommends the Companion ... but admits to not having fully checked it, yet.
And indeed, under closer scrutiny, the Companion, more specifically, the third printing of its first edition, reveals some flaws, partly because the book is so accurate that even minor flaws strike the attentive reader who is moderately experienced in Perl. Other flaws mislead the attentive beginner and worry the experienced Perl programmer, the more so because no errata have been published, yet. Most significant examples:
Needless computation in a few code examples suggests bad programming practice.
Logical truth is subtly misconceived, because context and the undefined value are introduced too late.
Packages, files, modules, blocks, and local (lexically scoped!) variables are not related to each other in sufficient generality, of which the reader is not notified, however.
Operators are not clearly classified (unary,binary,trinary vs scalar vs list operators). Here, the Companion should have improved on the Camel.
Despite its flaws, I wish I had learned Perl from the Companion rather than from the Camel, except for the relation of perl to Unix, which the author mostly omits and for good reason, concentrating on all-purpose Perl and the broader relation of Perl to computer science instead, in particular, on the relation of Perl to other programming languages and to algorithms and data structures, many of which latter are built in to perl or its library. Of these, Chapman discusses unbounded strings over the full character set of perl, integer and real numbers, sequences (lists), stacks, queues, deques, sets, structures (records), trees, closures, persistent hashes and other symbol tables (dictionaries, hashes, ...), with the help of which latter he implements a multi-map as an abstract data type, leading over to object classes in Perl, of which he presents a filehandle class whose objects he recommends over other filehandles. Classic example algorithms discussed include a single pass recursive descent compiler with a lexical analyzer based on a regular expression, topological sorting, and external merging assisting the sort function built-in to perl. No familiarity with these algorithms is required. The (graphic) treatment of Perl's references (type-checked pointers) is outstanding. Exception handling is covered. Code references are related to nonstandard control structures, for example, table-driven ones. The treatment of object orientation in Perl is very clear, the underlying philosophy and resulting advantages and deficiencies are thoroughly discussed, tradeoffs identified. The references claim to be complete, whereas the book is (intentionally) far from being comprehensive; hence, it does not replace the Camel. Note that the Companion is not just a cookbook, bag of tricks, or table of commandments; rather, it is a systematic, coherent, and didactic account of perl, to be studied from cover to cover. Exercises have been added to the third printing and are available from Wiley online.
Chapman emphasizes that types in Perl are another means for the programmer to express himself, rather than an obstacle to dodge. He adequately compares Perl with the Unix shell and shell utilities, C, Lisp, Awk, functional languages, Python, SQL, LaTeX, HTML, PostScript, Pascal, and Java, though mostly just in the form of occasional remarks. He also compares it with Fortran, Cobol, C++, Tcl, BCPL, Modula-3, and Snobol, that I don't know enough about to criticize. I would have preferred Icon over Snobol, because Icon descends from Snobol like Perl but has more recent relevance and is another one of those maverick languages Chapman takes such delight in; Chapman misses out on spreading the word about Icon. Another language Chapman enjoys is English, whose relation to Perl he exploits, especially for rationalizing Perl's funny prefix characters.
The book is also practical, because it discusses the full source code of useful applications; furthermore, because it addresses system dependencies for Unix, MacOS, MS-DOS descendants, and (rarely) VMS; in general, it presents the least common denominator of what perl does on these systems. Applications discussed include an EBNF to LaTeX translator (the above compiler) generating the syntax diagrams of the book, CGI-scripting, more specifically, Berkeley-DB-driven virtual web pages including forms, generated with the help of CGI.pm, and a noninteractive web client. Chapman outlines the structure of the Perl library and presents various ways of interfacing to its modules, so the reader need not reinvent the wheel. Some module interfaces are presented in more detail. Literal programming is demonstrated. Throughout the book, examples of useful text processing and bookkeeping are given. Not only plain text but also binary data is processed.
However, the DBMS interfaces of perl are only touched upon. The relation between Perl and SGML/XML is confined to the special case of making perl generate HTML. Syntax diagrams are incomplete; they are intended as idioms (anyone would have a hard time making them complete). Typing is neglected, even the static and dynamic type checking of perl, which features both of them, indeed, but to different extents and for different purposes. Multithreading is skipped entirely. Occasionally, information in the Companion is obsolete but never a crucial point.
The book is typeset in LaTeX and adequately so; hence, it is more extensive than it looks, despite its humane type area. Cross-references, special notices, footnotes, and a thorough hierarchical concept index spanning twelve pages make it more accessible. Fragments of (always complete) source code examples are interleaved with related explanatory paragraphs. Unfortunately, section numbers are scarce. Figures show bad printer calibration. There are almost no typos, even though the cover designer has misspelt Perl as PERL, for inscrutable because aesthetic reasons.