Errata


Print Print Icon

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 "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



Version Location Description Submitted By Corrected
Printed Page 4
Fifth paragraph, first sentence

Reads "Perl 9 tries to fill the gap", but should read "Perl tries to fill the gap". The 9 did not show up in the original sources or the QCs, but is in the book. Go figure.

brian d foy
brian d foy
O'Reilly AuthorO'Reilly Blogger 
Oct 2008
Printed Page 4
Fifth paragraph, first sentence

Reads "Perl 9 tries to fill the gap", but should read "Perl tries to fill the gap". The 9 did not show up in the original sources or the QCs, but is in the book.

Anonymous 
Safari Books Online 6.5
9th paragraph? The csh example of setting an environment variable

the setenv example should not have an = for csh.

Instead of:

% setenv CHARACTER=Fred

It should be:

% setenv CHARACTER Fred

Note from the Author or Editor:
Change as noted

Anonymous 
Safari Books Online 9.5.1
9th paragraph (using Safari)


The code " s#(.*)#$1#g; " will delete all of the text, not just the "BOLD" text.

Note from the Author or Editor:
This is also page 142 of the printed edition

The regex should in the second code example is missing the HTML tags and should read:

s#<BOLD>(.*)</BOLD>#$1#g

Anonymous 
Safari Books Online 13.14
Exercise #1

The last clause in the paragraph states: "but don't try show the contents."

Note from the Author or Editor:
should read "but don't try to show the contents."

Anonymous 
Printed Page 27
last paragraph of Subsection "Scalar Variables"

The first is on page 27, last paragraph of Subsection "Scalar
Variables": There I read
Scalar variables in Perl are always referenced with the
leading $&.

Should this be
Scalar variables in Perl are always referenced with the
leading $.

Note from the Author or Editor:
fix as reported

Anonymous  Oct 2008
Printed Page 27
4th paragraph

"Scalar variables in Perl are always referenced with the leading $&."
The "&" must be removed. It's correct in the 'Safari books online' version

Note from the Author or Editor:
Change as noted

Anonymous  Oct 2008
Printed Page 27
last paragraph of Subsection "Scalar Variables"

The first is on page 27, last paragraph of Subsection "Scalar
Variables": There I read
Scalar variables in Perl are always referenced with the
leading $&.

Should this be
Scalar variables in Perl are always referenced with the
leading $.

Note from the Author or Editor:
Change as noted.

Anonymous 
Printed Page 30
the small example

page 30, the small example.
If $meat has never recieved a variable, then $barney in
$barney = "fred ate a $meat";
has the value "fred ate a " and not "fred ate a", so the trailing " "
of the strings should remain?

Note from the Author or Editor:
On the second code second of page 30, the code comment reads

$barney is now "fred ate a"

it should read

$barney is now "fred ate a "

with a trailing space

Anonymous  Oct 2008
Printed Page 30
the small example

If $meat has never recieved a variable, then $barney in
$barney = "fred ate a $meat";
has the value "fred ate a " and not "fred ate a", so the trailing " "
of the strings should remain?

Note from the Author or Editor:
Change as noted

Anonymous 
Printed Page 85
2nd footnote

``use 5.6'' should read: ``use 5.006''

Note from the Author or Editor:
change as noted

Anonymous 
Printed Page 95
paragraph 7, first sentence

``http://www.stonehenge.com'' is not a hostname, ``www.stonehenge.com'' is...

Note from the Author or Editor:
change http://www.stonehenge.com to www.stonehenge.com as noted

Anonymous 
Printed Page 111
2nd code snippet

A copy/paste error from the 1st snippet on the same page:

The pattern should be /(.)(.)\2\1/, instead of /y(.)(.)\2\1/, and the output message should be something like "It matched a palindrome!\n".

Note from the Author or Editor:
The error isn't in the regex, it's the print statement. In the second example, change the print statement to:

print "It matched a after the y"

Anonymous 
Printed Page 112
last code example, right above "Alternatives" section heading

Change

$_ = "aa11bb";

to

$_ = "xaa11bb";

Note from the Author or Editor:
Change as noted

brian d foy
brian d foy
O'Reilly AuthorO'Reilly Blogger 
Printed Page 112
Last pattern-match code snippet

The pattern /(.)(.)\g{-1}11/ will not be matched from the string "aa11bb".

However, if the string contained, for example, "aaa11bb", the pattern would be matched.

The existing pattern could be modified to /(.)\g{-1}11/ to achieve a match with the existing string: "aa11bb".

Note from the Author or Editor:
This is the last code snippet before the "Alternatives" section in chapter 7. Change the code to read:
------
use 5.010;
$_ = "daa11bb";
if (/(.)(.)\g{-1}11/) {
print "It matched!\n";
}
-----

The change is the addition of the letter "d" at the beginning of "aa11bb".


Duane Klaming 
Printed Page 128
last paragraph, second sentence

``This may seem familiar, and for good reason: these automatic memory variables are what the pattern test program (from Chapter 7) was using in its line of "mystery" code, [...]''

That pattern test program is not in chapter 7; it's in chapter 8, four pages after the quoted text above. Thus these automatic match variables don't seem familiar to the first-time-reader...

And, BTW, ``chapter'' should not be capitalised in the parentheses ;-)

Note from the Author or Editor:
In the paragraph starting with "The message shows the string..", change the entire paragraph to:

The message shows the string as C<(Hello)( there,)( neighbor)>,
showing the three automatic match variables in action. We'll show
more of those variables in a moment.

Anonymous 
Printed Page 130 f.
chapter ``Precedence''

The first paragraph talks about four levels of precedence. But then five levels are listed in the table and in the enumeration following it. Both level 4 and 5 are said to be "the lowest level" there...

Note from the Author or Editor:
Change "4. The lowest level of precedence" to "4. The next-to-lowest level of precedence"

Anonymous 
Printed Page 142
4th paragraph, it's the first regex on the page.

In the latest edition(5th) on this page, the example provided is:
"I'm talking about the cartoon with Fred and <BOLD>Wilma</BOLD>!

And here's a substitution to remove those tags. But what's wrong with it?
s#(.*)#$1#g;

The problem is that the star is greedy[t]. What if the text had said this instead?
I thought you said Fred and <BOLD>Velma</BOLD>, not </BOLD>Wilma</BOLD>

In that case, the pattern would match from the first <BOLD> to the last </BOLD>, leaving intact the ones in the middle of the line. Oops! Instead, we want a nongreedy quantifier."

The problem is NOT just the quantifier, the first regex and the following description saying that it would match the bold tags is incorrect. That regex matches the *whole* string! Here is the following paragraph to clarify my point:
"The nongreedy form of star is *?, so the substitution now looks like this:
s#<BOLD>(.*?)</BOLD>#$1#g;
And it now does the right thing."

The point I'm trying to make is that it is clear that <BOLD></BOLD> was intended to be included in the first regex, of which is a major error. The correction would simply be:
s#<BOLD>(.*)</BOLD>#$1#g;

This is greedy, as the paragraph states, but the tags are included as they should be. Thus, to answer the question: "But what's wrong with it?" to which the answer supplied was "The problem is that the star is greedy." - that is not the only problem! The problem is that the HTML tags were completely left out of the regex! :)

Note from the Author or Editor:
There is missing text. The regex in the second code example on page 142 should be

s#<BOLD>(.*)<BOLD>#$1#g;

Anonymous 
Printed Page 165
second to last code example

Change

foreach my $try ( 0, undef, '0', 1, 25 ) {

to remove the "my"

foreach $try ( 0, undef, '0', 1, 25 ) {

Note from the Author or Editor:
Change as noted

brian d foy
brian d foy
O'Reilly AuthorO'Reilly Blogger 
Printed Page 175
2nd paragraph

'... rather than the double colon we used with moreinfo="none">File::Basename' includes the extraneous markup 'moreinfo="none">'.

Note from the Author or Editor:
change as noted

Anonymous 
Printed Page 176
last code example

Change

foreach my $param ( param() )

To remove the "my"

foreach $param ( param() )

Note from the Author or Editor:
Change as noted

brian d foy
brian d foy
O'Reilly AuthorO'Reilly Blogger 
Printed Page 188
3rd paragraph

On lines 3, 4 and 5, the text "The bitwise operator you'll need to use the bitwise operators. These are the operators that perform binary math operations on values." is interpolated and should be deleted.

Note from the Author or Editor:
Change noted sentences to "The bitwise operators perform binary math operations on values."

Anonymous  Oct 2008
Printed Page 188
chapter "Bitwise Operators", first paragraph

Sentences 2 and 4 are identical; sentence 3 is a mixture of sentences 5 and 1. Thus sentences 2 and 3 (or sentences 3 and 4) need to be deleted.

Note from the Author or Editor:
The first paragraph under "Bitwise operators" should read:

"When you need to work with numbers bit-by-bit, as when working with
the mode bits returned by C<stat>, you'll need to use the bitwise
operators. These are the operators that perform binary math operations
on values. The bitwise-and operator (C<&>) reports which bits are set
in the left argument I<and> in the right argument. For example,"

After the "For example,", continue as printed

Anonymous 
Printed Page 201
4th paragraph, first line

There is a missing space in "ln-s"; it should be "ln -s".

Note from the Author or Editor:
Change as noted

Anonymous  Oct 2008
Printed Page 202
first paragraph, last sentence

"it's a symlink, but it doesn't exist"

should read

"it's a symlink, but the file it references doesn't exist"

or similar.

Note from the Author or Editor:
change to "it's a symlink, but its target doesn't exist"

Anonymous 
Printed Page 204
4th paragraph, second line

"on directory per call" should be "one directory per call".

Note from the Author or Editor:
Change as noted

Anonymous  Oct 2008
Printed Page 204
4th paragraph

"... it can only remove *one* directory per call:"

Note from the Author or Editor:
change "can only remove on directory per call:" to "can only remove one directory per call:" with an "e" after the "on"

Anonymous 
Printed Page 206
first paragraph, last line

The text 'moreinfo="none">' at the beginning of the line appears to have been interpolated and should be deleted. Possibly this is a markup command with its leading "<" missing.

Note from the Author or Editor:
Remove the moreinfo="none"> before "stat" on the last line of the first paragraph

Anonymous  Oct 2008
Printed Page 206
1st paragraph

'... same type of values returned from the moreinfo="none">stat function ...' includes the extraneous markup 'moreinfo="none">'.

Note from the Author or Editor:
Change as noted

Anonymous 
Printed Page 206
section 13.14, Exercise #1

The last clause in the paragraph states: "but don't try show the contents" instead of "try to show"

Anonymous 
Printed Page 219
Code above Exercises

The code doesn't sort correctly. In it family_name 'a' is compared to itself, and personal_name 'a' is being compared to family_name 'b'.

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

should be:

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

Note from the Author or Editor:
Change as noted

Rose Roberts 
Printed Page 227
Example, bottom of page

When discussing fallthroughs in given/when statements, it appears the bottom example on p227 does not behave as expected. e.g. if the program is run as
$ ./fallthroughs.pl Frederick

Then we get the output:

Name has fred in it
Name starts with Fred
I don't see a Fred

Which seems rather self contradictory.

Note that this was also a problem in perlsyn.pod (http://perldoc.perl.org/perlsyn.html - see fallthrough example) and has now been patched in the latest perl 5 development tree (see thread on http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-03/msg00375.html)

Regards

Martin

Note from the Author or Editor:
This was indeed a documentation problem. I figured the docs would be right and perl would change, but they ended up changing the docs.

This isn't just a problem, then, with the last example on page 227.

The example can also be:

use 5.010;

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

Martin Jackson 
Printed Page 227
bottom example

As Michael already stated in his unconfirmed errata, running the bottom example with Frederick as argument does a fall-through right down to the default case. This happens since the argument begins with Fred and the check is continued after matching to both fred and ^Fred, Frederick isn't equal to Fred so we continue to the default.

A change of logic might be good in this case, the best case would be to find Fred, if we can't we'd settle for Frederick, and if that's not possible just having fred would be OK.

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

Staying with the logic of your example, one could also "unless /fred/i" at the end of the default's say.

Note from the Author or Editor:
This is basically how I'm rewriting all the Fred examples.

Tarik Ku 
Printed Page 229
second when statement on the second example

The books says

when( ! /fred/i } { #dumb
~ => this should be a ,,)'' and not a ,,}''

It is a syntax error.

Note from the Author or Editor:
Change as noted

Anonymous 
Printed Page 231
code sample in exercise 4

Change the line with foreach, which is missing a parenthesis. The new line should be have a left parenthesis after the ..

foreach my $divisor ( 2 .. ( $number/2 ) ) {

Note from the Author or Editor:
Change as noted

brian d foy
brian d foy
O'Reilly AuthorO'Reilly Blogger 
Printed Page 289
answer to excercise 2 (chapter 15)

The excercise asks to print "Fizz", "Bin" and "Sausage", but the answer prints "fizz", "buzz" and "sausage" (Bin vs buzz, and also note the case...).

Note from the Author or Editor:
Change ' buzz' to ' bin', as noted

Anonymous 
Printed Page 295
2nd paragraph line 3 and 3rd paragraph line 1

"also know as" instead of "also known as"

Note from the Author or Editor:
Change as noted. This is in Appendix B in the second paragraph.

Tarik Ku