By Developers, For Developers

Historical errata for Modern Perl, Fourth Edition

PDF PgPaper PgTypeDescriptionFixed onComments
33ERROR

The “Numeric Size Limits” note references a 64-bit build, but provides 32-bit limits.

It seems to automatically support signed and unsigned 64-bit integers..
signed integers go from –9_223_372_036_854_775_808 to 9_223_372_036_854_775_807
unsigned integers go from 0 to 18_446_744_073_709_551_615

perl -e ‘printf “%d %d %u\
”, 1<<63, ~(1<<63), ~0’
–9223372036854775808 9223372036854775807 18446744073709551615

19TYPO

Text says

  1. with use utf8; enabled
    package Ingy::d&ouml;::Net;

Should say

package Ingy::döt::Net;

With “ö” being the utf8 character in question.

88TYPO

The discussion of numeric operators seems to have replaced literal ‘<’ and ‘>’ characters with ‘lt’ and ‘gt’ characters. For example, the spaceship operator (<=>) has become “lt=gt”:

“Several comparison operators impose numeric contexts upon their operands. These are numeric equality (==), numeric inequality (!=), greater than (gt), less than (lt), greater than or equal to (gt=), less than or equal to (lt=), and the sort comparison operator (lt=gt).”

88TYPO

In the section starting “Several comparison operators impose numeric contexts upon their operands. These are numeric equality (==), numeric inequality (!=), greater than (gt), less than (lt), greater than or equal to (gt=), less than or equal to (lt=), and the sort comparison operator (lt=gt).”

The correct values for the for the operators should be:

‘gt’ should be ‘>’
‘lt’ should be ‘<’
‘gt=’ should be ‘>=’
‘lt=’ should be ‘<=’
‘lt=gt’ should be ‘<=>’

29ERROR

This falls between ‘typo’ and ‘technical error’ — under “Unicode in Your Programs” a pound/yen conversion example is given to show the use of Unicode currency symbols in code.

In the paper text, no currency symbols are used. Instead, there are words, ex:

sub pound_to_yen { … }

I checked the PDF and the correct symbols are there.

94TYPO

In the equivalent version of greet_one the conditions on the two die statements are backwards. _ < 1 should go with "too few arguments" and _ > 1 should go with “too many arguments”

81TYPO

The output of Dumper shows:

‘meals’ => {

It should show:

‘objects’ => {

73TYPO

At the bottom of the page, where there’s

my @cards = qw( K Q J 10 9 8 7 6 5 4 3 2 A );

The “Q” in that line of code is bold as if it’s the q() operator. The “my” and “qw” are correctly bold.

75SUGGEST

In discussion of hash references, it states “assigning an anonymous hash to a standard hash produces a warning about an odd number of elements in the hash.” In my Perl 5.20.3, it gives me “Reference found where even-sized list expected” which is more clear, but doesn’t match the text. I know the error message has changed over time, but it might be good to discuss the variations.

I also suggest that you discuss the opposite problem, of “my $x = ( foo => 1 )”, since that’s just as common and the “Useless use of a constant in void context” doesn’t really tell the user the real problem.

These mismatches are very common on StackOverflow.

31TYPO

Another two charset encoding errors as per errata #79114 and #79380:

“my $hello = ”iexclHola, “;”
The “iexcl” almost certainly is meant to be a single non-ASCII character.

“to form JosAtilde”
The “Atilde” almost certainly is meant to be a single character, and not a word spelled out.

100TYPO

“a new call frame, an data structure”
should be “a data structure”

123ERROR

$AUTOLOAD =~ /::(\\w+)$/;>

The > at the end is spurious and erroneous.

127TYPO

“‘caat’ matches/”

Spurious /. Perhaps meant to specify the whole regex as per line above it. Alternatively, all 4 lines of the example here could be consistent in their output.

134ERROR

“alternations always include the entire fragment to the nearest regex delimiter, whether the start or end of the pattern, an enclosing parenthesis, another alternation character, or a square bracket.”

I don’t think “or a square bracket” applies here: I can’t think of any way that it does, since an alternation character is taken as literal in square brackets, and square brackets surrounded by atoms simply becomes part of the fragment with the atoms.

136ERROR

$safe_feline and the second $disastrous_feline have the same definition. Almost certainly, the second $disastrous_feline should instead match the first $disastrous_feline definition with (?=) used instead of (?!).

137TYPO

“The multiline operator, /m”
Technically in perl jargon, as per perlre, /m is a modifier, not an operator.

192SUGGEST

“You’ve seen functions, classes, and data structure used to…”
Perhaps change to “data structures”. Even if you assume data is plural here, it makes sense that if we are talking about plural functions and plural classes we also are talking about plural structures. In fact, since “data” is just and adjective to “structure”, you can deduce the correct grammar by omitting “data” completely, which of course makes singular “structure” distinctly incorrect.

232TYPO

say ‘They’re equal, whatever that means!’ if numeric_equality @nums, 10;

That single quote in the string needs to be escaped somehow. Also, after that single quote the font style goes back to normal (from italic) when it should be italic to the final single quote. Also, the text after the final single quote should be normal and not italic.

110TYPO

There are copious boldface formatting flaws throughout the book where letters and words that denote perl builtin functions and operators are being used in a different context but are still printed in boldface. For instance, using the word “list” as a string literal like qw(list) should not be boldface, yet it is.

It appears an automated tool was used to set boldface, and the tool isn’t smart enough yet. I list below all the errors I spotted, I’m sure there are many more. Many of them could be eliminated by changing the tool to not boldface words/letters that begin with an uppercase letter, and words/letters that follow a backslash. Most of the rest would require the trickier step of determining if the word was inside some sort of quoting / literal such as s///, qw(), etc.

Also see related errata #80358.

My list is formatted as (<specific incorrect bold word(s)>)

110 use Sub::Identify (Sub)
121 package Proxy::Log; (Log)
121 Log::method_call (Log)
135 $text =~ /\\Q$literal_text\\E/; (Q)
136 $space_cat = qr/(?<=\\s)cat/; (s)
136 $spacey_cat = qr/\\s+\\Kcat/; (s)
138 s/liver and onions/ (and)
138 [;\
\\s]* (s)
138 ATTR \\s+ (s)
138 STRING\\s+\\* (s)
194 qw( list of arguments ) (list)
195 $wanted_package->import; (import should be bold, especially if require above it is bold)
210 if Scalar::Util::tainted (Scalar)
236 qw( list of values) (list and values, repeated 3 times on page)

63TYPO

Second to last paragraph:

“In a boolean scalar context, this ratio evaluates to a false value, so remember that instead of the ratio details.”

The ratio evaluates to true value instead of false. Note that empty hash yields ‘0’ in scalar context, so it’s considered as false.

80SUGGEST

The associated excerpt:

You can also use for’s implicit aliasing to avoid the use of an intermediate
reference (though note the lack of my):

($entree, $side) = @{ $_ }{qw( entree side )} for $meals{breakfast};

It may be worthwhile to exlain (e.g. in form of note), that using my inside statement modifier like this would yield undefined result (see note at the end of perlsyn at #Statement-Modifiers), so it should always be avoided.

9TYPO

“My” should not be bolded in: say if /My name is/;
(towards the top of the page)

11TYPO

(“readline” discussion at the top of the page)
“What’s more readable, glob ’.html’ to <.html>?”
should be:
“What’s more readable, glob ’.html’ or <.html>?”
?

16SUGGEST

I believe it is considered bad form to wrap a line such that the continuation begins with
a punctuation character.
‘.’ in 3rd paragraph
‘,’ in 5th paragraph

20SUGGEST

The bolding of the variable names “keys”, “values”, & “array” on pgs. 20, 21, 23, etc.
is confusing to the reader. It is not obvious why these appear in bold face. I’m
guessing it’s because there are perl core functions called “keys” and “values” and
uppercase “ARRAY” is a built-in array type??? However, in these instances the usage
is simply as variable names, so they should probably not be bolded.

38SUGGEST

In the “Ternary Conditional Operator” example, since the point
being made is equivalence, it would probably be best to use
either the call to the built-in ‘time’ function or the ‘$time’ variable
in both constructs.

55SUGGEST

“Almost no one uses these return values.” at the bottom of the page should probably
read “Almost on one uses the return values from ‘push’ and ‘unshift’”. The return
values from ‘pop’ and ‘shift’ are used often (e.g., using array as a stack, accessing
arguments in a function).

180TYPO

(top of page)
“The feature is working to your satisfaction, run the entire test suite …”
should read:
“When the feature is working to your satisfaction, run the entire test suite …”
or:
“Once the feature is working to your satisfaction, run the entire test suite …”

183TYPO

(middle of page)
“… any custom warnings you or the libraries you use will also be fatal …”
should read:
“… any custom warnings emitted by you or the libraries you use will also be fatal …”

33ERROR

Wait, does 64-bit perl store 32-bit integers? Or is it a typo and that’s supposed to be (2*63)–1 instead of (2*31)–1 ? Even better: add sample code that allows the reader test the actual range in their perl interpreter.

Here is the text from the book:

What’s the maximum size of a value you can represent in Perl? It
depends; you’re probably using a 64-bit build, so the largest
integer is (2**31) - 1 and the smallest is (2**31) —but see perldoc perl
number for more thorough details.

53SUGGEST

this:
\tisnt $i, ‘pig’ , ‘$i overwritten with a number’;
I suppose is intended to be
\t#$i is overwritten with a number.

88TYPO

This is in the paragraph talking about numeric operators that impose numeric context on their operands. The last paragraph here names the operators incorrectly:

Greater than is written as ‘gt’ (should be >), less than is written as ‘lt’ (should be <), greater than or equal is written as gt= (should be >=), less than or equal is written as lt= (should be <=) and sort comparison is written as lt=gt (should be <=>).

81TYPO

The line beginning with “numbers” should end with a comma, not a semicolon.
The “print” line should be “print Dumper( $complex_structure );” - there is a “my” at the beginning which does not match the actual varialbe name.

246SUGGEST

In the Index, under “: (colon)”, add an entry for “attribute declaration” referencing Chapter 5, Attributes (Paper page number 118).

33ERROR

On Page 33 (Chapter 3, The Perl Language, Values), the “Numeric Size Limits” box says “… you’re probably using a 64-bit build” but then goes on to say “so the largest integer is (2**31)–1 …”.

That’s incorrect / a typo - for a 64-bit build, the largest/smallest integers are (2*63)1 /(2*63).

Categories: