Errata

Mastering Perl

Errata for Mastering 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
Chapter 8, subroutines as arguments, section on Object::Iterate

Code snippet has only one colon in package name:

use Object:Iterate qw(igrep imap);

my @filtered = igrep {...} $object;

my @transformed = imap {...} $object;

Lucas Theisen  Aug 08, 2014 
Printed Page 5
3rd paragraph excluding code blocks

"It's just like the beginning of string anchor \A, except for where \G anchors at the current match position."

Poor wording, somewhat mangles the intended meaning in a way that could mean the opposite. It almost seems like originally it was "except whereas \A anchors... \G anchors" and was erroneously edited.

Perhaps could be:

"It's just like the beginning of string anchor \A, except that \G anchors at the current match position."

tcordes  Feb 16, 2014 
Printed Page 8
2nd paragraph excluding code blocks

"If it matched a f double quote mark", where the "f" is in a strange font, possibly a formatting markup artifact?

tcordes  Feb 16, 2014 
Printed Page 13
2nd code block

Script name probably intended to be "nested_caret_n.pl" not "nested_carat_n.pl", as it is demonstrating $^N (caret-N).

tcordes  Feb 16, 2014 
Printed Page 25
5th paragraph

"this program as ex <newline> plain_regex.pl": spurious newline. Correct filename is shown in following code block.

tcordes  Feb 16, 2014 
Printed Page 26
3rd code block

"perl -Mre=debug explain_regex" should be
"perl -Mre=debug explain_regex.pl" to match previous examples.on page 25.

tcordes  Feb 16, 2014 
Printed Page 33
8th code block

As per previous paragraph ("and using the full path to echo"), "echo" should be qualified with the full path, like "/bin/echo".

Strangely, the example still works, even with PATH unset, probably because it is using the shell's builtin echo, or perhaps because even with PATH unset, perl's "system" function seems able to find things in /bin.

tcordes  Feb 16, 2014 
Printed Page 35
2nd paragraph

Spurious newline: "Perl <newline> TaintCheck". Used in code block below it is shown correctly. Perhaps this is on purpose as a deliberate formatting style choice, but it strikes me as odd.

tcordes  Feb 16, 2014 
Printed Page 89
last sentence

"I won't cover all of this profile's features here ... but I'll give you enough to get started ..."

Except for mentions in "Further Reading", there is nothing else about Devel::NYTProf in the rest of the chapter, so the claim is simply false.

Gregory Sherman  Aug 08, 2017 
Printed Page 99
first sentence after code

"The output looks just like the times output I showed previously ..."
On page 98, the output of a call to time is shown, which is apparently what is being referred to, so the sentence should be "...the time output ..."

Gregory Sherman  Aug 10, 2017 
Printed Page 101
2nd sample output block after 2nd paragraph

The 1st and 2nd example invocations of "perl glob_opendir.pl" on the page are correct, but the 3rd example, directly after the 2nd, runs "perl big_dir.pl", a perl program which is not defined anywhere in this chapter. It appears that it should instead be yet another "perl glob_opendir.pl", as the example is to show that repeating the same command results in differing (timing) output.

tcordes  Dec 19, 2014 
Printed Page 126
beginning of code block after 2nd paragraph

The command line invocation wraps to the next line and the wrapped part is not in bold, breaking the convention of bolding the whole command line. The whole thing should be in bold, and perhaps some sort of indication of line continuation should be present so it is clear it is a continuation of the command line and not program output.

perl japh_encoder_decoder_rot13.pl japh_p* |
perl japh_encoder_decoder_rot255.pl -

tcordes  Dec 19, 2014 
PDF Page 128
3rd paragraph

Describing Perl Critic violation levels, it says
"Higher numbers are less severe, with 5 being the least severe. " - it should say that higher numbers are more severe, with 5 being the most severe.

Tim Teasdale  Aug 18, 2014 
Printed Page 128
1st paragraph, 2nd sentence

"It takes Perl source and make it harder"
should be
"It takes Perl source and makes it harder"

tcordes  Dec 19, 2014 
Printed Page 137
3rd paragaph, last sentence

"$global comes back to its original values"
should be
"$global comes back to its original value"

$global is a scalar and can only be one value at a time, and so can only have one "original value".

tcordes  Dec 19, 2014 
PDF Page 142
Code sample on the top of the page (before Aliasing section)

Top of the page:

use v5.10;
$foo = "Some value";
$bar = "Another value";
who_am_i( *foo );
who_am_i( *bar );

sub who_am_i {
local *glob = shift;
say "I'm from package " . *glob{PACKAGE};
say "My name is " . *glob{NAME};
}

The output when running the above is:

I'm from package main
My name is glob
I'm from package main
My name is glob

Compare with the book (page 141):

I'm from package main
My name is foo
I'm from package main
My name is bar

To me, it seems like *glob{NAME} is not copied along when aliasing in the who_am_i() sub (local *glob = shift). I am using perl version 5.22.1. Was this supposed to work on earlier perl's?

Håkon Hægland  Aug 12, 2016 
Printed Page 174
1st code example

%diff -u original_file updated_file original_file.diff>

Looks like markup formatter ate the > in the correct position before original_file.diff, turned off the bold formatting at that point and left a spurious > after it. No shell I know accepts the > *after* the file name, so the code as-is fails to run. This bold-disappears error appears a few times in the book. I will list them all separately.

tcordes  Feb 27, 2015 
Printed Page 186
2nd last paragraph

"Hook::Lex::Wrap" should be "Hook::LexWrap" as per examples on previous page. "Hook::Lex::Wrap" doesn't exist on CPAN.

tcordes  Feb 27, 2015 
Printed Page 192
the shell commands under the 3rd paragraph.

<C: set DEBUG=2 # Windows>>
should be
C:\>set DEBUG=2 # Windows

Anonymous  Jan 11, 2015 
Printed Page 198
GetOptions() call in program and first sentence of explanation

"In this example I've also created aliases for some switches by specifying their alternative names with the vertical bar, |.

At least with the latest version of GetOptions() in Getopt::Long, this is not actually the case. Any substring of a switch name - as long as it starts at the first character and does not clash with another switch name - will be accepted by GetOptions(). So, not only is there no need for "|d" in 'debug|d', but "d", "de", "deb", and "debu" will automatically work as alternative names on the command line.

Gregory Sherman  Aug 14, 2017 
Printed Page 203
1st code block

/bin/sh and bash shells will require "export" before each of the environment variable names, otherwise the called "./program" will never see the values you are trying to set, as they remain local vars to the shell, not env vars. As is, the code does not work as intended.

tcordes  Feb 27, 2015 
Printed Page 203
3rd code example

Probably markup formatter typos:

<% perl -le 'print "Interactive!" if -t STDOUT' output.txt>>

should have the first < deleted, the last > deleted and the 2nd last > moved before output.txt.

Also, as with other examples, the bold has been inadvertently turned off before the word output.txt.

tcordes  Feb 27, 2015 
Printed Page 210
1st code block

If the final else { last; } executes, the print $fh at the very bottom of the code will try to print on an unopened file handle. The print needs to confirm first $fh was opened successfully somehow. Same applies to the "last if $try++ >= 2" test from page 209.

tcordes  Feb 27, 2015 
Printed Page 216
1st paragraph

This doesn't mean, however, the the programmer has ...

two "the"

Anonymous  Jan 11, 2015 
Printed Page 216
first code block and the following paragraph

if( defined $@ and length $@ ) {
..; # catch die message and handle it
}

The $@ is a tricky variable. If the eval executed properly, it's the empty string,
which is a false but defined value. It's not enough to look for false ...

-------------------------------------------------------------------------------------------------------
It is enough to look for "false" - or rather "true".

From the 4th edition of Programming Perl - "eval" definition:
If there is a trappable error (including any produced by the die operator), eval ... puts the error message (or object) in $@. If there is no error, $@ is
guaranteed to be set to the null string, so you can test it reliably afterward for errors.
A simple Boolean test suffices:
eval { ... }; # trap run-]time errors
if ($@) { ... } # handle error

Gregory Sherman  May 18, 2018 
Printed Page 219
last code example

'line' -> __LINE__ - 1,

will have to be changed to __LINE__ + 6 if you want to what is says is desired in paragraph 2: have the line be the line of the die. Probably when first writing this code the author die'd directly on the Hash::AsObject->new line instead of creating an intermediate temp var $error.

Also, Data::Dumper is not used anywhere in that code example and its use line can be deleted.

tcordes  Feb 27, 2015 
Printed Page 226
bad_call program and output

First, the second line of the program is
#bal_call.pl
, but it's run as
%perl bad_call.pl
The online sample code (which, like the rest, is in a directory named +1 of the actual chapter) is in a file named bal_call.pl

Second, the output shown is wrong:
It should be
I'm die-ing in badcall! at bal_call.pl line 6.
( "...or bad_call.pl ...")

Gregory Sherman  Aug 16, 2017 
Printed Page 227,228
output of local_math.pl and private_croak.pl

output of both programs:
Can't divide by zero! at ... line 6.
should end with "7."

Gregory Sherman  Aug 16, 2017 
Printed Page 241
table 12-1

%l Shortcut for %c %f (%L)

should be

%l Shortcut for $C $F (%L)

(uppercase)

tcordes  Feb 27, 2015 
Printed Page 245
sentences below log messages

"In that example, the level in Foo was DEBUG, so it was a lower level than that in Foo.Bar."

On Page 244, Foo.Bar is assigned the INFO level, which according to page 238, is below DEBUG. Therefore the sentence should read "... it was a higher level .."


Gregory Sherman  Aug 17, 2017 
Printed Page 251
3rd paragraph

Text reads "The seek built-in" then the example below uses sysseek. Probably meant to say sysseek in the text.

tcordes  Feb 27, 2015 
Printed Page 251
1st code example and its output

You are setting the ISBN in the code to 0596527241 but in the sample output it is 144939311X

tcordes  Feb 27, 2015 
Printed Page 251
last paragraph, 2nd sentence

"(PBM)" should be "(BMP)" as the code below in two places says BMP but no where says PBM. Plus, there is no Image::Info::PBM, so it must be BMP he meant everywhere.

tcordes  Feb 27, 2015 
Printed Page 251
last paragraph, 3rd sentence

Saying "Here's a bit of code" ... "The while loop reads"... and then showing code without a while loop in it is a bit confusing. One sits there looking for the aforementioned while loop. Perhaps more code was meant to be included?

tcordes  Feb 27, 2015 
Printed Page 271
1st code example

if ( ref $isbns ) {

should be

if ( !ref $isbns ) {

tcordes  Feb 27, 2015 
Printed Page 281
last code example

The last part of the "In HTML" line needs a slash before the final i to be valid HTML, like:

PerlE<lt>/iE<gt> to

tcordes  Feb 27, 2015 
Printed Page 282
2nd code/run example

Probably markup formatter typos:

<% perldoc CGI cgi.txt>>

should be

% perldoc CGI >cgi.txt

Also, once again the bold is disabled before the end of the example line.

tcordes  Feb 27, 2015 
Printed Page 283
3rd code/run example

Formatting markup flaws created a huge mess that really munges the intended meaning.

< -e 'print dirname( < )' | xargs ls >>

Also, once again the bold gets disabled halfway through.

tcordes  Feb 27, 2015 
Printed Page 297
program

The print statement is misleading:
print " value is", $negated, "\n\n";
It should be
print "~ value is", $negated, "\n\n";

Gregory Sherman  Sep 06, 2017 
Printed Page 298
figure 15-1

Result is invalid, should be: 1010. The mask was probably intended to be different, as it's a bad example of masking since no bits in the first operand would be masked out, thus rendering the example somewhat pointless.

tcordes  Feb 27, 2015 
Printed Page 300
2nd paragraph, 4th sentence

"I pass the combination on exclusive lock ... and ..."

should be

"I pass the combination of exclusive lock ... and ..."

tcordes  Feb 27, 2015 
Printed Page 314
2nd code example

my $class = $classes[ $row++ % ($#class + 1) ];

should be

my $class = $classes[ $row++ % ($#$classes + 1) ];

Anonymous  Jan 16, 2015 
Printed Page 317
1st code example, near bottom

$self->STORE( $list_ref ) ) {

should have just one closing paren. As is it's a syntax error.

tcordes  Feb 27, 2015 
Printed Page 317
1st code example, about 2/3rds in

The call to carp has two strings, which must be joined with a dot. As is, it's a syntax error.

tcordes  Feb 27, 2015 
Printed Page 322
table 16-1

Semicolons occur willy-nilly. They should be consistent in the columns, and possibly made to match the sister table 16-2 p331 which is perfect.

tcordes  Feb 27, 2015 
Printed Page 330
1st paragraphc

"lowest common denominator"

should be

"lowest common multiple"

(or "least"). In math 24 is the LCM of 3 and 8, not the LCD. Of course, everyone knows what was meant, so this is a minor quibble.

tcordes  Feb 27, 2015