Errata

Learning Perl

Errata for Learning 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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
5.4
Fourth paragraph of section 5.4-don't know page #-reading electronically

Book probably reads:

fred
barney
betty


But online version displays:

fred
barney
betty

Note from the Author or Editor:
There should be some non-collapsing space in front of those words, so the beginning of each line starts with a space.

Anonymous  Jun 28, 2011  Oct 14, 2011
Other Digital Version
8
3rd paragraph (second full paragraph)

The first sentence of the 3rd paragraph ends "... even to the point that it's main implementation goes by the name Rakudo."

It should read "... that its main implementation ..." [it's --> its]

The word "it's" (with an apostrophe) is the contraction of "it is" or "it has". The word "its" (without an apostrophe) is the possessive form. In fact, not one of the possessive pronouns or adjectives in English is ever written with an apostrophe.

<aside>
Another popular error these days is to use "who's", which is the contraction of "who is" or "who has", instead of "whose", which is the relative possessive pronoun.
</aside>

Note from the Author or Editor:
Change as noted.

William Bresler  Aug 08, 2011  Oct 14, 2011
PDF, ePub, Mobi,
Page 12
last paragraph

"PFE (Programmer's Favorite Editor)" should be "PFE (Programmer's File Editor)"
http://www.lancs.ac.uk/staff/steveb/cpaap/pfe/

Note from the Author or Editor:
Change as noted

Tim Hofsommer  Apr 30, 2013  Dec 05, 2014
18
footnote

"(...) or via a piped open, which you�ll see in Chapter 14."

correct version is:

"(...) or via a piped open, which you�ll see in Chapter 16."

Note from the Author or Editor:
Change as noted

Grzegorz Szpetkowski  Jun 05, 2013  Dec 05, 2014
PDF
Page 30
chapter 2, scalar data

but a variable you use throughout a program should probably have a more descriptive name to not only remind you want [what] it does, but let other people know what it does

Note from the Author or Editor:
In the second to last line on p.30, "you want" should become "you what". This is the last sentence in the first paragraph of "Choosing Good Variable Names".

Anonymous  Sep 22, 2011  Oct 14, 2011
PDF
Page 34
3rd code example

This is the code example:

$code_point = ord( 'א' );

If you look closely, the closing quote, the closing parenthesis, and the semicolon are of a different font than the beginning.

Note from the Author or Editor:
Verify that it's all a code font

aphilipp  Jan 11, 2013  Dec 05, 2014
37
2nd line from bottom

"programmers? text editor"

should be

"programmer?s text editor"

Note from the Author or Editor:
Change as noted

Grzegorz Szpetkowski  Sep 03, 2011  Oct 14, 2011
PDF
Page 50
2nd para, 2nd line,

rule in Perl: as long you don�t change the meaning by removing the parentheses,

should be:

rule in Perl: as long _as_ you don�t change the meaning by removing the parentheses, (emphasis with underscore)

Note from the Author or Editor:
Change as noted

Anonymous  May 09, 2012  Dec 05, 2014
Printed
Page 51
First example, top of page

@array = qw( pebbles dino fred barney betty );
@removed = splice @array, 2; #remove everything after fred
# @removed is qw( fred barney betty )
# @array is qw( pebbles dino)

Shouldn't the first comment read "#remove fred and everything after" since "fred" is removed as well.?

Note from the Author or Editor:
Change as noted

Anonymous  Aug 16, 2011  Oct 14, 2011
55
3rd code listing

Compilation error (Global symbol "@rocks" requires explicit package name at) due to "use 5.012;" pragma. As I checked that pragma implies "use strict;", so you could change it to "use feature ':5.12';" (looks bad) or just change "@rocks" to "my @rocks" (latter solution looks simpler, because you have already "my( $index, $value )").

Note from the Author or Editor:
Change as noted

Grzegorz Szpetkowski  Aug 29, 2011  Oct 14, 2011
Printed
Page 55
.

You use lexical (my) variables in a code example on page 55 (The each
Operator) but you only formally introduce this concept on page 71.
and
You use "say" for output in a code example on page 55 (The each Operator)
but you only formally introduce this concept on page 102.

Note from the Author or Editor:
Under the section "The each Operator", change the code to:

use 5.012;

@rocks = qw/ bedrock slate rubble granite /;
while( ( $index, $value ) = each @rocks ) {
print "$index: $value\n";
}

Anonymous  May 19, 2014  Dec 05, 2014
PDF
Page 56
2nd paragraph

On page 56, second paragraph, there's a part explaining the different results from 2*3 and 2x3 and it says "The first gives you 8" which is wrong. 2*3 is 6 I believe unless you meant 2**3 which is actually 8 but then you have to correct 2*3 to 2**3.

Note from the Author or Editor:
Change "The first gives you 8 while the second gives you 222" to "The first gives you 6 while the second gives you 222"

Navid Paya  Aug 28, 2012  Dec 05, 2014
Printed
Page 56
2nd paragraph

The * in 2*3 is numeric multiplication, while the x in <2x3> is string replication. The first
gives you 8 ....

Should be 6 instead of 8.

This error has already been reported for the pdf Format.

Note from the Author or Editor:
Change as noted

Eckhard Stein  Jun 12, 2014  Dec 05, 2014
Printed
Page 65
towards bottom of page

On page 65, towards the bottom, you have the sentence:

"You normally take in those sorts of statements when you�re ready to deploy
your program."

I think perhaps you meant to say "take OUT".

Note from the Author or Editor:
Change as noted

Anonymous  May 19, 2014  Dec 05, 2014
Printed
Page 85
after 3rd paragraph

"can't open wimla: No such file or directory"

should be

"can't open wilma: No such file or directory"

Note from the Author or Editor:
Fixed in the sources

aphilipp  Jan 08, 2012  Jan 13, 2012
PDF
Page 89
1st footnote

Change "zero or one arguments" to "zero or one argument".

Note from the Author or Editor:
Change as noted unless it breaks house style.

aphilipp  Jan 21, 2013  Dec 05, 2014
96
3rd code line

binmode STDERR, ':encoding(UTF-8)';

should be

binmode STDIN, ':encoding(UTF-8)';

Note from the Author or Editor:
Change as noted

Grzegorz Szpetkowski  Sep 02, 2011  Oct 14, 2011
PDF
Page 104
1st paragraph

"Perl realizes that $fh is a filehandle"

should be

"Perl realizes that $rocks_fh is a filehandle"

Note from the Author or Editor:
Fixed in the sources

aphilipp  Jan 25, 2012  Dec 05, 2014
PDF
Page 104
5th code example, 1st line

This is the line:

print { $rock_fh }; # uses $_ by default

According to the documentation, only a real filehandle like FH can be used alone to print the contents of $_. Using an indirect filehandle as seen in this example gives a syntax error.

Note from the Author or Editor:
Remove that single line from the code and do not replace it with anything.

aphilipp  Jan 13, 2013  Dec 05, 2014
PDF
Page 115
before title 'Hash Functions'

$hash{ bar.foo } = 1; # that's the key 'foobar'

should be:

$hash{ bar.foo } = 1; # that's the key 'barfoo'

Note from the Author or Editor:
Change as noted.

chunzi  Aug 23, 2011  Oct 14, 2011
123
6th paragraph

if (/\p{Hex}\p{Hex}/) {

print "The string has a pair of hex digits.\n";

}

should be (to be suitable with previous [0-9A-Fa-f], character class):

if (/\p{AHex}\p{AHex}/) { # 22 different possible characters
print "The string has a pair of hex digits.\n";
}

Unicode property Hex_Digit is broader than ASCII_Hex_Digit (http://unicode.org/cldr/utility/properties.jsp).

Note from the Author or Editor:
Change as noted. We don't need the full-width versions of the characters.

Grzegorz Szpetkowski  Sep 19, 2011  Oct 14, 2011
123
5th paragraph

if (/\p{Digit}/) { # 411 different possible characters

should be (because of update for Perl 5.14 with Unicode Version 6.0.0):

if (/\p{Digit}/) { # 420 different possible characters

More information:
http://perldoc.perl.org/perluniprops.html
http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:General_Category=Decimal_Number:]

Note from the Author or Editor:
Update as noted.

Grzegorz Szpetkowski  Oct 16, 2011  Jan 13, 2012
127
1st paragraph

"Perl will create as many back references as it needs, so it assumes that you mean \111. Since you don?t have 111
(or 11) capture groups, Perl complains when it tries to compile the program."

I think that information is not quite true. Actually in such situation Perl treats clearly \111 as octal escape syntax (decimal 73). Check:

$_ = "aaIbb";
if (/(.)\111/) {
print "It matched!\n";
}

According to perlre only backreferences \1 through \9 are "guaranteed", for higher number Perl is smart enough to count left parentheses. I think that might be good option to make some footnote on this issue.

Note from the Author or Editor:
Fixed in the sources

Grzegorz Szpetkowski  Sep 14, 2011  Jan 13, 2012
129
footnote

"Even under Unicode semantics, the \s still doesn?t match the vertical tab, next line, or nonbreaking space."

That seems to be untrue in Perl 5.14:

#!/usr/bin/perl -w
use 5.014;
use charnames qw(:full);

my @chars = ("\N{LINE TABULATION}", "\N{NO-BREAK SPACE}", "\N{NEXT LINE}");
foreach (@chars) {
if (/\s/u) { # Unicode semantics explicitely by /u
printf "%s is matched\n", charnames::viacode(ord);
}
}

Result is (that is, only vertical tab is unmatched):

NO-BREAK SPACE is matched
NEXT LINE (NEL) is matched

Note from the Author or Editor:
I shouldn't have used "semantics" in the footnote because I wasn't considering the /u. The footnote really refers to the Unicode Space property.

Grzegorz Szpetkowski  Nov 03, 2011 
130
3rd line

there is:

"just like you did with /d:"

should be:

"just like you did with \d:"

Also you might consider dropping unnecessary square brackets on previous page (129), that is "/HAL-[\d]+" into "/HAL-\d+" (two occurences in code examples on that page).

Note from the Author or Editor:
Change the /d to \d, but leave the other suggestions as is.

Grzegorz Szpetkowski  Sep 04, 2011  Oct 14, 2011
Printed
Page 130
bottom of page, in Footnote

“See “Know your character classes under different semantics” at http://www.effectiveperlprogramming.com/blog/991.”

The link is no longer available, however, it can be found at:

http://www.effectiveperlprogramming.com/2011/01/know-your-character-classes/

Note from the Author or Editor:
Change as noted

Anonymous  Apr 08, 2015 
PDF
Page 130
second code snippet

The comment says that character class [\v\h] is the same as \p{Space} (which is true), but it also says that "it is no more than \s".

I would rather say, that it is quite opposite way: no less than \s, because \s:

- lacks vertical tab in older (pre 5.18) versions of Perl
- it's restricted to ANSI subset when /a modifier is turned on
- can be narrowed by locale modifier /l (note that \p{Space} does not care about locale)

Note from the Author or Editor:
This is true, but with the seventh edition coming out, I'll make the change there. Which is, no change.

Grzegorz Szpetkowski  Dec 19, 2015 
Printed, PDF
Page 131
Ecuador

At the end of Chapter 7, in the second paragraph within the 'Negating the Shortcuts' subsection, this text makes an uninvited intrusion to the text: "That means that you could now use /[0-9A-F]+/i to match hexadecimal (base 16) numbers, which use letters ABCDEF (or the same letters in lowercase) as additional digits."

It seems to me that these little lines of text have wandered off from Chapter 8, specifically from the subsection to where I'm sure it really belongs: 'Case-Insensitive Matching'. Actually, that Section had suspiciously little to say about the '/i' modifier in Perl and, if you just paste this text right at the end of the subsection, the feature's purpose becomes much more agreeable.

Note from the Author or Editor:
In the second paragraph under Negating the Shortcuts, change the sentence to read:


That means that you could now use /[0-9A-Fa-f]+/ to match hexadecimal

  Aug 09, 2014  Dec 05, 2014
Printed, PDF, ePub
Page 132
Exercise 5

Text is "Make a program that prints each line that has a two of the same nonwhitespace
characters next to each other."

The "a" before "two" should be removed.

Note from the Author or Editor:
Change as noted

Paul Trost  Nov 27, 2012  Dec 05, 2014
PDF
Page 137
last paragraph

U+0OBC is 1&#8260;4

should be:

U+00BC is 1&#8260;4

Note from the Author or Editor:
Change as noted. It should be all zeroes in that bit of code.

chunzi  Aug 25, 2011  Oct 14, 2011
PDF
Page 140
2nd paragraph

Change all instances of "\z" to "\Z".

Note from the Author or Editor:
Capitalize \z to \Z as noted in all instances as noted.

aphilipp  Jan 31, 2013  Dec 05, 2014
PDF
Page 142
last paragraph

the pattern would look like /^(fred(barney)/

should be:

the pattern would look like /\A(fred(barney)/

Note from the Author or Editor:
Change as noted

chunzi  Aug 28, 2011  Oct 14, 2011
143
1st code snippet

if (/\s(\[a-zA-Z]+),/) { # capture the word between space and comma

should be (just without backslash before '['):

if (/\s([a-zA-Z]+),/) { # capture the word between space and comma

Note from the Author or Editor:
Remove slash in front of square brace.

Grzegorz Szpetkowski  Sep 20, 2011  Oct 14, 2011
PDF
Page 147
at first footnote

you use \k<label:

should be:

you use \k<label>:


and, the footnote has the same issue:

A \k<label is slightly different

should be:

A \k<label> is slightly different

Note from the Author or Editor:
Change as noted

chunzi  Aug 29, 2011  Oct 14, 2011
Printed
Page 151
1st footnote

The first footnote is incorrect because nothing can come after the \z anchor (including newline). If the corresponding pattern had used \Z (which allows an optional newline after it), then the footnote would have been applicable.

Note from the Author or Editor:
Footnote deleted.

aphilipp  Oct 19, 2011  Jan 13, 2012
153
1st paragraph

See ?Answers to Exercises? on page 306 for answers to the following exercises.

should be (also with proper hyperlink to page 308 instead of 306):

See ?Answers to Exercises? on page 308 for answers to the following exercises.

Note from the Author or Editor:
This is the link from the Chapter 8 exercises to the Chapter 7 answers. The link should be from the Chapter 8 exercises to the Chapter 8 answers, on page 308.

Grzegorz Szpetkowski  Sep 26, 2011  Oct 14, 2011
153
Exercise 5.

For example, if the input string says I
saw Wilma yesterday, the up-to-five characters are ?yest?.

should be:

For example, if the input string says I saw Wilma yesterday, the up-to-five characters are ? yest?.

Note from the Author or Editor:
Fixed in the source. Thanks.

Grzegorz Szpetkowski  Nov 18, 2011  Jan 13, 2012
PDF
Page 192
2nd code example

Change "Set::Crossproduct" to "Set::CrossProduct".

Note from the Author or Editor:
Change as noted

aphilipp  Oct 13, 2012  Dec 05, 2014
PDF
Page 192
1st code section, 6th line

Change "brian" to "fred".

Note from the Author or Editor:
Change as noted

aphilipp  Oct 13, 2012  Dec 05, 2014
Printed
Page 200
5th code line

print $dt->ymd(''); # 20010423

should be

print $dt->ymd(''); # 20110423

Note from the Author or Editor:
Change as noted. The year should be 2011

aphilipp  Oct 27, 2011  Jan 13, 2012
Printed
Page 200
3rd code line from bottom

my @units = $duration->in_units( qw(year month day) );

should be

my @units = $duration->in_units( qw(years months days) );


Also, as there is no mention of the "in_units" method in the DateTime module documentation, some discussion regarding the creation of a "DateTime::Duration" object (resulting from the subtraction between $dt2 and $dt1) would have been helpful.

Note from the Author or Editor:
Corrected as noted.

aphilipp  Nov 06, 2011  Jan 13, 2012
Printed
Page 221
4th paragraph

"In Perl, you use the unlink operator with a list of the file that you want to remove"

should be

"In Perl, you use the unlink operator with a list of the files that you want to remove"

aphilipp  Jan 16, 2012  Dec 05, 2014
PDF
Page 244
last 3rd paragraph

So the comparison is $score{"fred"} <=> $score {"barney>"},

should be:

So the comparison is $score{"fred"} <=> $score {"barney"},

Note from the Author or Editor:
There's an extra > in that inline code. Remove it.

chunzi  Sep 12, 2011  Oct 14, 2011
Printed
Page 248
3rd paragraph

"When you finds one that does match"

should be

"When you find one that does match"

It is peculiar that this exact text appears in the previous edition without the typo.

Note from the Author or Editor:
Change as noted. Fixed in the repo.

aphilipp  Nov 16, 2011  Jan 13, 2012
Printed
Page 249
code at bottom of page

The smart match "@nums ~~ $result" gives a false result. Upon further investigation, I noticed that this problem was already discussed in the errata of the 5th edition (see submission for page 290). To summarize, this smart match now only works when the scalar comes before the array (i.e. "$result ~~ @nums").

Note from the Author or Editor:
I've removed this example from the sources.

aphilipp  Nov 19, 2011  Jan 13, 2012
Printed
Page 251
4th paragraph

In the paragraph starting with

"What if you have tow scalar variables? ..."

the scalar variables used in the code are called $fred and $barney. However, in the explanation following the code snippet, they are referred to as $scalar1 and $scalar2.

Note from the Author or Editor:
Change $scalar1 and $scalar2 to $fred and $barney as noted. This is in the paragraph immediately before the section heading "The given statement"

Varun Vats  Apr 30, 2012  Dec 05, 2014
Printed
Page 251
Last paragraph

The last sentence of the last paragraph says ( underscores only for emphasis):

"Each when block reports a different way that it found Fred, starting with the _least restrictive to the most_."

Assuming that you are using the second code snippet from the following page (253), and not the first (which does not seem to have any specific order), the sentence should mention "most restrictive to the least" instead.

<aside>
Sorry if this has been already fixed from aphilipp's reports.
</aside>



Note from the Author or Editor:
Change to "least restrictive to most" as noted.

Varun Vats  Apr 30, 2012  Dec 05, 2014
Printed
Page 252
first 2 code examples

Example #1:
==========
given ( $ARGV[0] ) {
when ( 'Fred' ) { say 'Name is Fred' }
when ( /fred/i ) { say 'Name has fred in it' }
when ( /\AFred/ ) { say 'Name starts with Fred' }
default { say "I don't see a Fred" }
}

Example #2:
==========
given( $ARGV[0] ) {
when ( $_ ~~ 'Fred' ) { say 'Name is Fred' }
when ( $_ ~~ /\AFred/ ) { say 'Name starts with Fred' }
when ( $_ ~~ /fred/i ) { say 'Name has fred in it' }
default { say "I don't see a Fred" }
}

The second example is supposed to be a rewrite of the first example, with the only difference being the use of explicit smart matching. But looking carefully, one can see that the second and third when conditions are reversed. Because of this, the output from each example can be different (as shown below).

Output for Example #1:
==================
$ perl5.10.1 switch.pl Frederick
Name has fred in it

Output for Example #2:
==================
$ perl5.10.1 switch.pl Frederick
Name starts with Fred

Also, the above example code is used as the basis for further examples throughout the remainder of this chapter. So any corrections to the above mentioned code should probably be applied to the rest of the chapter.

Note from the Author or Editor:
Fixed in the sources. Thanks,

aphilipp  Nov 20, 2011  Jan 13, 2012
Printed
Page 253
3rd paragraph

The following is the example code that corresponds to the text that is at issue:

given ( $ARGV[0] ) {
when ( $_ ~~ 'Fred' ) { say 'Name is Fred'; break }
when ( $_ ~~ /fred/i ) { say 'Name has fred in it'; break }
when ( $_ ~~ /\AFred/ ) { say 'Name starts with Fred'; break }
default { say "I don't see a Fred"; break }
}

The above code does not agree with the text. This example does not go from general to specific. It is untrue that Perl doesn?t test any of the when conditions if the argument matches /fred/i. The when condition "if the argument is exactly Fred" does in fact get checked because it is the second when block that stops the entire control structure.

As this paragraph was borrowed from the 5th edition, I suspect that it was not updated to reflect changes made to the example code. The other possibility is that some of the lines in the example code are not in the correct order (as pointed out in the errata submission for page 252).

Note from the Author or Editor:
Fixed in the sources

aphilipp  Nov 21, 2011  Jan 13, 2012
Printed
Page 253
2nd code example

The "# OOPS!" comment next to the first when block should be deleted.

Note from the Author or Editor:
Fixed in the sources

aphilipp  Nov 21, 2011  Jan 13, 2012
PDF
Page 253
1st and 2nd code examples, 1st paragraph

Code Example #1
==============
given ( $ARGV[0] ) {
when ( $_ ~~ 'Fred' ) { say 'Name is Fred'; break }
when ( $_ ~~ /fred/i ) { say 'Name has fred in it'; break }
when ( $_ ~~ /\AFred/ ) { say 'Name starts with Fred'; break }
default { say "I don't see a Fred"; break }
}

Paragraph #1
===========
This doesn't work very well for the problem, though. Since our example goes from specific to general, if the argument matches Fred, Perl doesn't test any more of the when conditions. I don't get to check if the argument is exactly Fred because the first when block stops the entire control structure.

Code Example #2
==============
given ( $ARGV[0] ) {
when ( $_ ~~ 'Fred' ) { say 'Name is Fred'; continue }
when ( $_ ~~ /fred/i ) { say 'Name has fred in it'; continue }
when ( $_ ~~ /\AFred/ ) { say 'Name starts with Fred'; continue } # OOPS!
default { say "I don't see a Fred" }
}

Discussion
=========
The order of the when conditions in these code examples is not consistent with the other examples in this section. I assume that the order should be as follows:
when ( $_ ~~ 'Fred' )
when ( $_ ~~ /\AFred/ )
when ( $_ ~~ /fred/i )

Paragraph #1 does not seem to be well adapted since the previous edition. Previously, the order went from general to specific. Because of this, it made sense to call attention to the fact that none of the other when conditions are tested if the argument matches /fred/i. But because we are now going from specific to general, it not longer seems meaningful. For example, if the argument matches Fred, then there is no need to test any of the other when conditions since we already know that they would match.

Also, the last sentence in the paragraph #1 is no longer applicable and should probably be removed.

Note from the Author or Editor:
That's probably a good idea

aphilipp  Jan 25, 2012  Dec 05, 2014
Page 254
Code just before the exercises

Page 254 in the 7th Edition and 246 in the 6th

Line 5 in the code is

$personal_name{$a} cmp $family_name{$b} or

but it looks like it should be

$personal_name{$a} cmp $personal_name{$b} or

Note from the Author or Editor:
Yes, those should be the same hash as noted

Steve Wright  Sep 07, 2018 
PDF, Other Digital Version
Page 255
2nd paragraph

Actually is:
when ( ! /\A-?\d+\.\d+\z/ ) { #smart

Should be:
when ( ! /\A-?\d+\.\d+\z/ ) { #dumb

Since "Negated expressions, including a negated regular expression, don?t use a smart match either." (top of Page 256)

Note from the Author or Editor:
Change as noted

Anonymous  Jul 24, 2011  Oct 14, 2011
PDF
Page 256
all 3 code examples

The main logic in the code examples is as follows:

foreach ( @names ) {
when ( /fred/i ) { say 'Name has fred in it'; continue }
when ( /\AFred/ ) { say 'Name starts with Fred'; continue }
when ( 'Fred' ) { say 'Name is Fred'; }
default { say "I don't see a Fred" }
}

It logically makes more sense to reverse the order of the when conditions. By putting the general when condition at the bottom, we ensure that the default does not get invoked when any of the when conditions are true. This can be illustrated as follows:

foreach ( @names ) {
when ( 'Fred' ) { say 'Name is Fred'; continue }
when ( /\AFred/ ) { say 'Name starts with Fred'; continue }
when ( /fred/i ) { say 'Name has fred in it'; }
default { say "I don't see a Fred" }
}

Also, the above change would make the logic consistent with the other examples in the chapter.

Note from the Author or Editor:
That's probably a good idea.

aphilipp  Jan 26, 2012  Dec 05, 2014
PDF
Page 269
5th paragraph, 1st sentence

This is the sentence:

"The pipe opens can also take more than three commands."

Change "commands" to "arguments".

Note from the Author or Editor:
Change as noted

aphilipp  Mar 03, 2013  Dec 05, 2014
Printed
Page 283
3rd code snippet

The statement

my $barney = eval { $fred / $dino }

is missing a semicolon ( ; ) at the end.

Note from the Author or Editor:
Change as noted

Varun Vats  May 16, 2012  Dec 05, 2014
Printed
Page 286
4th paragraph

"If the keyword eval doesn't come directly before a block of code in curly braces, as you saw for most of this section, there's no need to worry - that's the safe kind of eval."

should be

"If the keyword eval comes directly before a block of code in curly braces, as you saw for most of this section, there's no need to worry - that's the safe kind of eval."

Note from the Author or Editor:
Fixed in the source

aphilipp  Dec 02, 2011  Jan 13, 2012
Printed
Page 288
Last paragraph

In the code snippet following the last paragraph, the autodie pragma should be used to make the open statement die on error.

Also, the open statement should be enclosed in an eval block (as given in the autodie documentation) to be able to have a meaningful execution of the given-when block. If it is not, $@ will be an empty string and the default case will be executed even on an error.

Note from the Author or Editor:
The last line of code on p288 should change to:

use autodie;
eval { open my $fh, '>', $filename; # still dies on error };

Varun Vats  May 17, 2012  Dec 05, 2014
Printed
Page 292
last code example

use List::MoreUtils qw(none any all);

if (none { $_ > 100 } @numbers) {
print "No elements over 100\n"
} elsif (any { $_ > 50 } @numbers) {
print "Some elements over 50\n";
} elsif (all { $_ < 10 } @numbers) {
print "All elements are less than 10\n";
}

In this example, we can never drop down to the last conditional expression. Success is always achieved in one of the first 2 conditional expressions. Perhaps the code can be modified so that all of the conditional expressions have a chance for success.

Note from the Author or Editor:
Good catch! Fixed in the source so that all three branches might execute.

aphilipp  Dec 03, 2011  Jan 13, 2012
PDF
Page 293
3rd paragraph

It then goes back to @family

should be:

It then goes back to @abc

Note from the Author or Editor:
Change as noted

chunzi  Sep 19, 2011  Oct 14, 2011
PDF
Page 293
3rd noncode paragraph

"It then goes back to @family to get its next element,..." should read "It then goes back to @abc to get its next element,..."

Note from the Author or Editor:
The printed book has this mistake, but my sources don't. That's odd. It's correct in the current sources.

Ben Altman  Dec 04, 2011  Jan 13, 2012
Printed
Page 293
between 3rd and 4th paragraphs

Some of the elements of @large_array contain the undef value. Therefore the following change should be made:

a 1 dino b 2 c 3 ...

should be

a 1 dino b 2 undef c 3 ...

Note from the Author or Editor:
There should have been two spaces after the 2. I've also added a short paragraph after that output to explain it.

aphilipp  Dec 04, 2011  Jan 13, 2012
295
First exercise

$ perl -e 'print "Hello, World\n"'

Since this doesn't work for Windows folks, you could add another footnote for them. Here is SO question, which covers that topic greatly:

http://stackoverflow.com/questions/4352026/why-doesnt-this-perl-one-liner-work-on-windows

Note from the Author or Editor:
There's not much we can do in Chapter 1 because we haven't shown them anything that can fix this. We can add a footnote though.

Grzegorz Szpetkowski  Oct 22, 2011 
Printed
Page 310
2nd paragraph

In the solution to Chapter 9 Exercise 2, the text refers to bareword filehandles IN and OUT. But the corresponding code uses scalar variables $in_fh and $out_fh to store the filehandles. The text should correlate with the code.

Note from the Author or Editor:
Fixed in the source.

aphilipp  Oct 22, 2011  Jan 13, 2012
PDF
Page 310
2nd paragraph

"Once the filehandles $in and $out are opened, the real program can begin."

should be

"Once the filehandles $in_fh and $out_fh are opened, the real program can begin."

Note from the Author or Editor:
Fixed in the sources

aphilipp  Jan 24, 2012  Dec 05, 2014
Printed
Page 313
code for Chapter 11 Exercise 1

Exercise 1 on page 201 asks to print a list of all of the modules that came with Perl 5.14. Therefore the following change should be made to the solution on page 313.

my %modules = %{ $Module::CoreList::version{5.006} };

should be

my %modules = %{ $Module::CoreList::version{5.014} };

Note from the Author or Editor:
Fixed in repo as noted.

aphilipp  Nov 01, 2011  Jan 13, 2012
Printed
Page 313
code for Chapter 11 Exercise 2

In the first solution to Exercise 2, the localtime function was meant to be called in list context, with the resulting list being stored in an array. Therefore $t should be changed to @t, as shown below.

use DateTime;

my $t = localtime;

my $now = DateTime->new(
year => $t[5] + 1900,
month => $t[4] + 1,
day => $t[3],
);


should be


use DateTime;

my @t = localtime;

my $now = DateTime->new(
year => $t[5] + 1900,
month => $t[4] + 1,
day => $t[3],
);

Note from the Author or Editor:
Fixed in sources as described

aphilipp  Nov 02, 2011  Jan 13, 2012
Printed
Page 317, 318
code for Chapter 13 Exercises 2 & 3

To be consistent with Exercise 1, the following change should be made to the code in Exercises 2 and 3:

if ($dir =~ /\A\s*\Z/) { # A blank line
chdir or die "Can't chdir to your home directory:
$!";
}

should be

if ($dir =~ /\A\s*\Z/) { # A blank line
chdir or die "Can't chdir to your home directory: $!";
}

Note from the Author or Editor:
It looks like some bad wrapping in exercises 2 and 3. Thanks,

aphilipp  Nov 16, 2011  Jan 13, 2012
PDF
Page 317, 318
Chap 13 Ex 1,2,3

This is the code section:

chomp(my $dir = <STDIN>);
if ($dir =~ /\A\s*\Z/) { # A blank line

Because there will never be a newline after the end-of-string anchor, change "\Z" to "\z":

chomp(my $dir = <STDIN>);
if ($dir =~ /\A\s*\z/) { # A blank line

Note from the Author or Editor:
Change as noted

aphilipp  Feb 20, 2013  Dec 05, 2014
Printed
Page 323-327
first line of each solution

Page 247 explains that smart matching is broken in Perl 5.10.0 and that most of the problems disappeared in Perl 5.10.1. To be consistent with the examples presented in Chapter 15, the following change should be made to the exercise solutions:

use 5.010;

should be

use 5.010001;

Note from the Author or Editor:
Fixed in sources.

aphilipp  Nov 24, 2011  Jan 13, 2012
Printed
Page 328
5th code line in Chapter 16 Exercise 4

sub my_usr2_handler { say 'Caught INT. Exiting.'; exit }

should be

sub my_int_handler { say 'Caught INT. Exiting.'; exit }

Note from the Author or Editor:
Fixed in the sources, thanks.

aphilipp  Nov 28, 2011  Jan 13, 2012
Printed
Page 328
code for Chapter 17 Exercise 1

chomp(my @strings = <FILE>);

should be

chomp(my @strings = <$fh>);

Note from the Author or Editor:
Fixed in the sources.

aphilipp  Dec 07, 2011  Jan 13, 2012
Printed
Page 330
6th paragraph

"has a strftime subroutine the takes"

should be

"has a strftime subroutine that takes"

aphilipp  Dec 09, 2011  Jan 13, 2012
PDF
Page 335
2nd paragraph, 1st sentence

This is the sentence:

"In Chapter 16, we mentioned the map and grep list-processing operators."

Change "Chapter 16" to "Chapter 17".

Note from the Author or Editor:
Change as noted

aphilipp  Mar 04, 2013  Dec 05, 2014
345
2nd paragraph from bottom

"That way, treating your
ASCII or Latin-1 strings as UTF-8 should work out just fine (but not UTF-16, where
every character takes up at least two bytes)."

UTF-8 encoding uses two bytes for Latin-1 characters (excluding ASCII subset), e.g. COPYRIGHT SIGN (U+00A9) is encoded as C2 A9 (UTF-8), whereas Latin-1 stores it as single byte A9, so binary representation is diffrent (UTF-8 encodes as one byte only these code points from U+0000 to U+007F).

Note from the Author or Editor:
Remove "or Latin-1" from that sentence. Although Latin-1 and Unicode share the same code numbers, the encoding isn't the same in UTF-8.

Grzegorz Szpetkowski  Sep 03, 2011  Oct 14, 2011
Printed
Page 346
4th paragraph

Two subroutines for decomposition supplied by Unicode::Normalize are mentioned. They are NFD and NFKD. While NFD has a description of what it does, NFKD does not. Below are two sentences from the text, where the second one seems to be incomplete:

"You use the NFD subroutine (Normalization Form Decomposition), which turns canonically equivalent forms into the same decomposed form."

"You use the NFKD subroutine (Normalization Form Kompatibility Decomposition)."

Shouldn't this second sentence also include a brief description of what NFKD does?

Note from the Author or Editor:
Corrected in the source.

aphilipp  Dec 10, 2011  Jan 13, 2012
Printed
Page 346
4th paragraph

"while the "yay" message should"

should be

"while the "yay" messages should"

aphilipp  Dec 24, 2011  Jan 13, 2012
PDF, Other Digital Version
Page 347
Figure C-2

In the right part of the image it says
SMALL LETTER A, U+00E4
It should be
SMALL LETTER A, U+0061

Note from the Author or Editor:
Change as noted

Johan Andersson von Geijer  Jun 25, 2011  Oct 14, 2011
347
Figure C-2

"DIAERESIS, U+00A8"

should be (because of NFD transformation):

"COMBINING DIAERESIS, U+0308"

Note from the Author or Editor:
Change as noted

Grzegorz Szpetkowski  Sep 03, 2011  Oct 14, 2011
PDF, Other Digital Version
Page 348
1rst paragraph, 2nd sentence.

Actually is:
The NFKD forms miss the compatible equivalents:

Should be:
The NFD forms miss the compatible equivalents:

Note from the Author or Editor:
Change as noted

Johan Andersson von Geijer  Jun 25, 2011  Oct 14, 2011
PDF
Page 349
second title

Reading from or Writing to STDOUT or STDERR

should be:

Reading from STDIN or Writing to STDOUT or STDERR

Note from the Author or Editor:
Change as noted

chunzi  Sep 22, 2011  Oct 14, 2011
PDF
Page 349
footnote

The website link:

http://www.effectiveperlprogramming.com/blog/972

is no longer valid (404 Error - Not found).

Its content is available now at:

http://www.effectiveperlprogramming.com/2011/01/use-the-n-regex-character-class-to-get-not-a-newline/

Note from the Author or Editor:
Change as noted.

Grzegorz Szpetkowski  Sep 19, 2015 
PDF
Page 351
1st code

foreach my $arg ( @ARGV ) {
push @new_ARGV, decode $codeset, $_;
}

should be

foreach my $arg ( @ARGV ) {
push @new_ARGV, decode $codeset, $arg;
}

or

foreach ( @ARGV ) {
push @new_ARGV, decode $codeset, $_;
}

Note from the Author or Editor:
Change in the first code block. Change the instance of $_ to $arg

mkamimura  Mar 16, 2013  Dec 05, 2014
PDF
Page 353
2nd and 3rd entries in the index

Two index entries for the /a and /r modifiers are the wrong location. They should be placed with the other modifiers. The index should look as follows:

/a modifier, 129, 136
/g modifier, 156
/i modifier, 134
/l modifier, 136
/r modifier, 158
/s modifier, 134
/u modifier, 136
/x modifier, 135

Note from the Author or Editor:
Change as noted

aphilipp  Jan 24, 2012  Dec 05, 2014
PDF
Page 354
index below A

/a modifier, 136

should be

/a modifier, 129, 136

Note from the Author or Editor:
The /a modifier index entry should be modified as noted.

aphilipp  Apr 25, 2012  Dec 05, 2014
Printed
Page 361
index

The following should be added to the index:

readlink function, 228

Note from the Author or Editor:
Change as noted

aphilipp  Jan 19, 2012  Dec 05, 2014
PDF
Page 361
index below R

The following should be added to the index:

/r modifier, 158

Note from the Author or Editor:
There should be an index entry for /r, as noted

aphilipp  Apr 25, 2012  Dec 05, 2014
PDF
Page 365
first paragraph

Fifth Edition

should be:

Sixth Edition

Note from the Author or Editor:
Change as noted

chunzi  Sep 22, 2011  Jan 13, 2012
Printed,
Page 365
3rd paragraph

"He was been an instructor and author"

should be

"He was an instructor and author"

Note from the Author or Editor:
In the "About the author" for brian, change "He was been" to "He was", as noted.

mward333  Apr 20, 2012  Dec 05, 2014