Programming Perl

Errata for Programming Perl

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date Submitted
Mobi Table Of Contents

"The table of contents" is missed from latest mobi revision (August 2015), when mobi is viewed on a Kindle 3, unlike precedent revisions.

Marco  Nov 07, 2015 
Printed Page 15
2nd sentence of 1st *complete* paragraph

The word "package" is broken across lines - but without hyphenation, and thus appears as two separate words: "pack" and "age", which could confuse those who are unfamiliar with the [Perl] language (though it should become clearer when viewing the example below the offending paragraph). I'd suggest either adding the hyphen: (pack-age) or shifting the white-space around a bit to get the word to appear on one line, un-hyphenated (the former is probably easier)

Adam Stoller  Mar 21, 2017 
Printed Page 20-21
Starting from around the middle of page 20 through the middle+ of page 21

This is more what I see as a questionable omission rather than an actual error with the text. While it is certainly possible to name the script "gradation", the norm (which does not appear to be mentioned in this section) is to use the file extension ".pl" which serves at least two purposes: 1. Most *programming* editors pick up clues with regard to what kind of syntax highlighting, indentation, and such to use from the extension of the file (this can be set manually, but it's nicer to have it happen automatically) 2. On Non-Unix (at least on Windows) systems, the extension can be used to facilitate the proper reference to the executable to use to process the file, e.g.: C:\> assoc .pl=perl .pl=perl C:\> ftype perl=c:\activestate\perl\bin\perl.exe %1 %* perl=c:\activestate\perl\bin\perl.exe %1 %* From that point on, assuming "" is on your PATH environment, you could just say: C:\> rather than needing to say: C:\> perl

Adam Stoller  Mar 22, 2017 
Printed Page 29-30
Table 1-4 (page 29) and last sentence (page 30)

Maybe this is minor, but I think it's kind of serious. Starting with the last sentence and then working back to the table, "Of course, these logical operators can also be used within the more traditional constructs, such as the if and while statements.", then looking at the table: $a && $b | And | $a if $a is false, $b otherwise The above is true in terms of assignments (something I never realized) - but not in terms of conditional statements, where '&&' requires that both $a and $b evaluate to true in order for the expression to be true, otherwise it evaluates to false (something I'm sure you're aware of). It seems questionable to me to introduce these operators, that table, and than that sentence without then explaining how the operators work when used within the "more traditional constructs". I think the first table should somehow indicate the context in which the information applies, and that another table (1-5?) created to show how they work in the other context.

Adam Stoller  Mar 22, 2017 
Printed Page 57
2nd line of 1st paragraph

Similar to an earlier note I sent, this involves a monospaced word wrapped across lines without hyphenation. In this case: "...fp_excep tion_field_type, ..." there should be a hyphen after 'fp_excep'

Adam Stoller  Mar 24, 2017 
ePub Page 89
2nd text paragraph

"When you're not implicitly assigning to $_ in a $_ loop ..." should be "When you're not implicitly assigning to $_ in a while loop ..."

Gregory Sherman  Sep 25, 2017 
Printed Page 197&219
explanation of \W on both pages

In the table on pg 197, \W = "Match any nonword character" \w matched characters include "connector punctuation", which implies more than one character On page 219, under "Boundaries": "\W includes all punctuation characters (except the underscore)" This conflicts with the earlier text implying that more than just the underscore is included in "connector punctuation"

Gregory Sherman  Sep 28, 2017 
Printed Page 230
last regex

/foo((?x-i) bar/ #Enables /x and disables /i for "bar" should be " bar" - "foobar" would not match if x was removed from regex due to space before "bar"

Gregory Sherman  Sep 29, 2017 
Printed Page 255
10th non-blank line

This is more of a suggestion than errata. Regarding the example line, s/(\$\w+)/$1/eeg; I struggled with understanding why perl did not seem to evaluate the replacements with just one "e". $a = "Hello"; $b = "world"; $c = "."; $_ = '$a $b$c'; s/(\$\w+)/$1/eg; say; Then, I came up with an example which helped to show me what was going on. $a = "Hello"; $ab = "Goodbye cruel"; $_ = '$a world!'; s/(\$\w+)/$1/e ; printf "\n%-8s: ", '/$1/e' ; say; s/(\$\w+)/$1/ee ; printf "\n%-8s: ", '/$1/ee' ; say; $_ = '$a world!'; s/(\$\w+)/$1.b/ ; printf "\n%-8s: ", '/$1.b/' ; say; $_ = '$a world!'; s/(\$\w+)/$1.b/e ; printf "\n%-8s: ", '/$1.b/e' ; say; $_ = '$a world!'; s/(\$\w+)/$1.b/ee; printf "\n%-8s: ", '/$1.b/ee'; say; An example like that with bit of explanation might be helpful to other readers. Also, the following example can help to show how string interpolation and statement evaluation relate to each other. $a = "Hello"; $ab = "Goodbye cruel"; $_ = '$a world!'; /(\$\w+)/; say "$1.b"; say eval "$1.b"; say eval eval "$1.b"; print "\n"; say '$1.b'; say eval '$1.b'; say eval eval '$1.b';

Arnold Cross  Jan 10, 2019 
Printed Page 261
1st & 3rd regexes

The first and third regexes are both said to match parentheses and are identical, except that the third one starts with \w+ and uses (?-1) instead of (?1) My admittedly limited testing shows that either (?-1) and (?1) work in this regex that matches parentheses. An explanaiton is in order if this is actually the case. In any event, it's not clear what is meant by the "previous" group vs. "count[ing] forward", especially in "a group you're already in the middle of".

Gregory Sherman  Oct 01, 2017 
Printed Page 281
Second paragraph of second code example

Variable $INCLUÍR_NINGUNOS is used as an example of non-ascii identifier with an accent over the second "I". If this was meant to be Spanish (as it seems) it is wrong. Incluir doesn't have an accent, much like fluir and fluido. Please see You may want to replace that word for the real accented word INCLUSIÓN to keep the example with similar meaning.

José Luis González  Mar 30, 2013 
PDF Page 308
1st and 2nd code output sections

I am finding some differences between my output and what is shown in the book: "script=Common A" should be "script=Common". Every 2nd line should show "mirrored=N".

aphilipp  Aug 11, 2012 
PDF Page 327
Table 7-1. Prototypes to emulate built-ins

The last paragraph of page 327, underneath Table 7-1, starts: "Any backslashed prototype character (shown between parentheses in the left column above) represents an actual argument..." However, none of the examples in the table (in the 4th edition PDF at least) contain any backslashes. I cross-checked my 3rd edition printed text, and the same table contains entries in the left column with backslashes. These 3 entries are (3rd edition printed, 4th edition PDF respectively): sub mypop (\@) vs. sub mypop (;+) sub mysplice (\@$$@) vs. mysplice (+;$$@) sub mykeys (\%) vs. sub mykeys (+)

David Ha  Dec 16, 2014 
Printed Page 350, 351
"dispatch" middle of 350, bottom of 351

On page 350: &{$dispatch{$index}}(1, 2, 3); Here the BLOCK is necessary. Without the outer pair of braces, Perl would have treated $dispatch as the coderef instead of $dispatch{$index} On page 351 The arrow is optional ... So you can shrink the previous code down to: $dispatch{$index}(1, 2, 3); There was no arrow to discard in the first place Is the second call legal syntax?

Gregory Sherman  Oct 04, 2017 
Printed Page 358
sub() call in middle of page

referring to the anonymous sub() call in block of code at top of page: ... you could have written it this way instead: *${name} = sub ($) ... To again work with uppercase options (like "RED"), it should be *${name} = *(uc $name} = sub ($) ...

Gregory Sherman  Oct 04, 2017 
Printed Page 360
code section (beginning with our $value)

In two say() calls, ${"value"} causes compilation errors, as double quotes can't be nested say "but ours is ${"value"}."; should be say "but ours is ", ${"value"}, "."; say "Outside, ${value} is again ${"value"}."; should be say "Outside, ${value} is again ", ${"value"}, ".";

Gregory Sherman  Oct 04, 2017 
Printed Page 511
5th line from bottom to start, but whole page is discussed

"Now the file will be empty, ..." may be true on (li|u)nix systems, but on win7 I'm finding that the cat call flushes the buffer before reading the file. The trap description is still correct, but the only line missing from the output is "The End". I suggest the following changes to make this section more clear. 1) Put the extra function in the package from the start. That way the reader will not be inclined to think that the trap has something to do with the presence of the extra function. Also, lines that serve identical purposes in STORE and the extra function should be identical. That way the reader will not spend time figuring out things that have nothing to do with the topic of the section. I suggest the following two functions between FETCH and DESTROY on page 510. sub STORE { my $self = shift; my $value = shift; print { $self->{FH} } "$value\n"; $self->{VALUE} = $value; } sub fileonly { my $self = shift; my $value = shift; print { $self->{FH} } $value, "\n"; } 2) For the first example (top of page 511), explain that although the tied variable cannot directly access the extra class method, that method can be accessed through the object of the tied variable. Use the following as the first example code. (All lines are identical to what's in the book, except that I replaced $fred=4; and I fixed the fourth line per my erratum submission of 25 May 2019.) use strict; use Remember; my $fred; tie $fred, "Remember", "camel.log"; $fred = 1; (tied $fred)->fileonly(4); $fred = 5; untie $fred; system "cat camel.log"; The output does not change from what's shown in the book. 3) For the second example, explain that since a reference to the object of the tied variable is returned by tie, it can be assigned to its own variable. That variable can then be used to access extra methods of the class. Use the following as the second example. (All lines are identical to what's in the book, except that I replaced two lines with "fileonly $x 4;".) use strict; use Remember; my ($fred, $x); $x = tie $fred, "Remember", "camel.log"; $fred = 1; fileonly $x 4; $fred = 5; untie $fred; system "cat camel.log"; 4) Now the trap can be discussed, but the symptom is either an empty file or a missing final line, depending on how the shell handles file buffering. From that point forward, the explanation is fine. With these changes it will be more clear to the reader that the assignment to $x is the source of the trap, and the reader will not need to do as much mental gymnastics to follow the discussion.

Arnold Cross  Jun 17, 2019 
Printed Page 533
top of page

"You can open a multistage pipline for input ..." . . . "But then you don't get ... multistage pipes ..."

Gregory Sherman  Oct 11, 2017 
Printed Page 544
explanation, code, and folowing programs

"... your socket programs should always start out like this ..." . . . # or IO::Socket::IP from CPAN for IPv6 use IO::Socket; --------------------------------------------------------------- IO::Socket::INET is used in subsequent programs IO:::Socket is never used in the rest of the chapter

Gregory Sherman  Oct 12, 2017 
Printed Page 546
2nd paragraphj

"That classs is an extra sockdomain method ..." was probably meant to be "That classs has an extra sockdomain method ..."

Gregory Sherman  Oct 12, 2017 
Printed Page 549
REQUEST loop and text below

"Even if you don't fork, the listen will allow ..." There is no call to listen() in the REQUEST loop.

Gregory Sherman  Oct 12, 2017 
Printed Page 613

Only the first "|" is new The next 3 lines have "!" instead and so repeat commands from page 612 In the next paragraphs, "|DBCMD" and "|PERLCMND" are mentioned, so the should have appeared above as forms of the "|" command

Anonymous  Jul 21, 2017 
Printed Page 650
last three lines

The three $shout examples all have backticks. I think only the second one was intended to have backticks. The other two should use double quotes in order to portray only one insecurity at a time.

Arnold Cross  Nov 21, 2019 
Printed Page 660
"Running as setuid ..." and code below

"Running as setuid, where taint mode is automatically on, is similary defeated with -u:" The command line and output which follow that sentence are identicial to the "-t" example above it.

Gregory Sherman  Oct 19, 2017 
Printed Page 691
2nd paragraph under "Efficiency"

"... you should profile your program (see Chapter 17) ..." should be "... you should profile your program (see Chapter 18) ..."

Gregory Sherman  Oct 20, 2017 
Printed Page 765
Program-Wide Special Variables

"... (except for @F ..." There is no @F in the list of special variables.

Gregory Sherman  Oct 25, 2017 
Printed Page 1041
last sentenceof next-to-last paragraph

"See the explanation of the %SIG hash in 28 ..." probably was meant to be: "See the explanation of the %SIG hash in chapter 25 ..." (but also mentioned starting at page 518 of chapter 15)

Gregory Sherman  Oct 31, 2017 
Printed Page 1043
first two paragraphs

"%H" occurs three times, but should be "%^H"

Gregory Sherman  Oct 31, 2017