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
Printed
Page 105
Where The text says that "/fred\w+barney/"

Date: Sat, 22 Nov 2008 20:52:56 -0800
From: Kurt Wall <kwall@kurtwerks.com>
Subject: Learning Perl, 4th Edition Errata

Hi,

Another outstanding O'Reilly book. One nit, which is likely irrelevant
now that the Llama book has moved on to its 5th (!) edition. In the 09/07
printing of the 4th edition of Learning Perl, the 4th paragraph of p. 105
is still not correct. The text says that "/fred\w+barney/" will match
"fred" followed by a space, a word, a space, and "barney". I believe this
is incorrect.

Noting in passing the typos in the errata page itself, the errata at
http://oreilly.com/catalog/9780596101053/errata/9780596101053.907 reads:

"(105) 4th Paragraph;
there should not be a space between teh text "/fred \w+" and "barney".
this may have been a formatting error as the result of the regular
experssion being spanned across two lines."

--- cut here ---
#!/usr/bin/perl -w

$_ = "wilma and fred and barney and betty";
print "matching '$_'\n";
if (/fred\w+barney/) {
print "$`<$&>$'\n";
} else {
print "no match\n";
}

$_ = "wilma and fredandbarney and betty";
print "matching '$_'\n";
if (/fred\w+barney/) {
print "$`<$&>$'\n";
} else {
print "no match\n";
}
--- and here ---

$ ./105.pl
matching wilma and fred and barney and betty
no match
matching wilma and fredandbarney and betty
wilma and <fredandbarney> and betty

If I'm missing something, I'm willing to be corrected.

Kind regards,

Kurt Wall
--
Abandon the search for Truth; settle for a good fantasy.

Note from the Author or Editor:
This is an error in the Fourth Edition. On page 105, third paragraph under "Character Class Shortcuts", second line ends with "/fred\w+barney/". Change that to "/fred \w+ barney/" with a single code space around the "\w+".

Anonymous  Nov 24, 2008 
Printed
Page 247
Code at bottom and on next page

The solutions to exercises 6 and 7 in chapter 12 use modules when the text has yet to even mention what a module is.

Note from the Author or Editor:
It's an errata. The fix is in the Fifth Edition, so there is nothing to do.

Anonymous  Jun 27, 2008 
Printed
Page xv
below 2nd paragraph

http://www.oreilly.com/catalog/lperl4/

NOW READS:
http://www.oreilly.com/catalog/9780596101053/

Anonymous    Jan 01, 2006
Printed
Page 4
first line

It's a retronym, not an acronym....
should be:
It's a backronym, not an acronym

Anonymous   
Printed
Page 48
1st sentence of last paragraph

"That's not to say that this section is in difficult to understand."
^^
NOW READS:
"That's not to say that this section is difficult to understand."

Anonymous    Apr 01, 2006
Printed
Page 52
1st paragraph

"If the person running the program types three lines and presses the proper keys
needed to indicate end-of-file, the array will have with three elements."

NOW READS:
"If the person running the program types three lines and presses the proper keys
needed to indicate end-of-file, the array will have three elements."

Anonymous    Jan 01, 2006
Printed
Page 52
The instruction line under the "Exercises" heading

See Appendix Q for answers...
->
See Appendix A for answers...

#######################################

Anonymous    Jan 01, 2007
Printed
Page 69
Paragraph 3

Now, before we go any further, we must be clear about something: this shortcut
workparticular, as a statement all on its own) it won't...

NOW READS:
Now, before we go any further, we must be very clear about something:
this shortcut works only if you write it just as we did. If you put
a line-input operator anywhere else (in particular, as a statement all
on its own) it won't...

Anonymous    Jan 01, 2006
Printed
Page 70
last paragraph

If the invocation arguments had been fred- betty, that
->
If the invocation arguments had been fred - betty, that

#######################################

Anonymous    Jan 01, 2007
Printed
Page 95
line 2

we could easily see see which ones

should read instead

we could easily see which ones

Anonymous   
Printed
Page 105
4th Paragraph

there should not be a space between teh text "/fred w+" and "barney". this may have been a formatting error as the result of the regular experssion being spanned across two lines.

Anonymous    Sep 01, 2007
Printed
Page 105
4th paragraph

One of the corrections in the 9/07 reprint was made incorrectly; I will describe this below.

On page 105, 4th paragraph, the phrase

A pattern such as /fredw+barney/

should read instead as

A pattern such as /fred w+ barney/

Note from the Author or Editor:
This is the third paragraph under "Character Class Shortcuts". The report also has a problem, though. The correct formatting is:

A pattern such as /fred \w+ barney/

There are spaces around \w+

Anonymous   
Printed
Page 106
Exercise 4 text changed to

Make a program that prints each line with a word that contains a
capital letter followed by lowercase letters. Does it match Fred but
neither fred nor FRED?

#######################################

Anonymous    May 01, 2007
Printed
Page 106
First line of the exercises

Change the line

See Appendix Q for answers to the following exercises:

it should read as

See Appendix A for answers to the following exercises:

Anonymous   
Printed
Page 113
2nd footnote

the memory of an completed pattern match.
->
the memory of a completed pattern match.

#######################################

Anonymous    Jan 01, 2007
Printed
Page 116
first footnote

A period is missing at the end of the first footnote.

Change:

"which is practically everywhere"

to:

"which is practically everywhere."

Anonymous   
Printed
Page 129
line 14

The line reads

print "Found 'wilma' at start of line
" if /^wilma/im;

Unfortunately, such "expression modifiers" are not explained until page 137. The first time that
we see an expression modifier explained is on page 137, line 3.

So the user has no idea on page 129 what such an expression means (although, admittedly, it is
easy to guess the meaning).

Note from the Author or Editor:
If you are reading the old edition, change that to

if( ... ) { ... }

Anonymous   
Printed
Page 162
line 4 from the bottom of the page

The phrase "this is as more efficient" does not make sense. Change this phrase to, for instance,
"this is efficient".

Note from the Author or Editor:
Change to "this is more efficient", without the "as".

Anonymous   
Printed
Page 168
paragraph 2

If we wanted all the non-dot files and we could say that...
->
If we wanted all the non-dot files, then we could say that...

#######################################

Anonymous    Jan 01, 2007
Printed
Page 177
middle of page

the sample snippet of code shown does not work. the rmdir() function accepts only a
single directory to delete, at one time. attempting to pass more than one directory
argument, as glob will do if there is more than 1 subdirectory under fred, will only
succeed in deleting the first directory.

rmdir glob "fred/*"

This is confirmed by the perldoc page on rmdir().

rmdir FILENAME
rmdir Deletes the directory specified by FILENAME if that directory
is empty. If it succeeds it returns true, otherwise it
returns false and sets $! (errno). If FILENAME is omitted,
uses $_.

Anonymous   
Printed
Page 177
middle of page;in addition to my previous note, I should also point out an error in

the description of the return value for the rmdir() function.
The following line is technically incorrect.
"As with unlink, rmdir returns the number of directories removed,
and if invoked with a single name, it sets $! in a reasonable manner
on a failure."

As pointed out earlier, rmdir() only accepts a single argument, and
if more than one is provided, it ignores all but the first. Additionally, the return value of rmdir() is either 1 upon
successful deletion of an empty directory, or 0 if no directory was deleted.

Anonymous   
Printed
Page 179
last paragraph before the exercises

change the phrase:

because it's primary purpose

to be instead:

because its primary purpose

Anonymous   
Printed
Page 179
exercise 1, last line

Change the phrase:

"but don't try show the contents."

to read instead:

"but don't try to show the contents."

Anonymous   
Printed
Page 191
sample code following paragraph 2 (second error)

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

#######################################

Anonymous    Jan 01, 2007
Printed
Page 191
line 1 of the exercises

Change the phrase

"See Appendix 1 for answers to the following exercises:"

to be instead

"See Appendix A for answers to the following exercises:"

Anonymous   
Printed
Page 198
Last paragraph

Unlike in the other cases where the word is used, 'system' has not been put in LucasFont's TheSans Mono Condensed, but has been left in Linotype Birka.

Note from the Author or Editor:
Change as noted

Anonymous   
Printed
Page 211
6th paragraph

The last sentence in the paragraph beginning "Well, that worked for Unix" reads "In that case, you'd have that machine's kind of filename string in $name, in that case." I think that you only want "in that case" once.

Anonymous   
Printed
Page 216
Exercises 2 and 3

Exercise 2: Get a list of filenames in the current directory. Use the C<Cwd>
module... then use the C<File::Spec> module...

Exercise 3: Using the output... ... use the C<File::Basename> module.

The strange formatting characters "C<>" HAVE BEEN DELETED.

Anonymous    Jan 01, 2006
Printed
Page 216
Exercise 2, third sentence

"Print the list of paths to standard outout with one path per line."

'outout' NOW READS 'output'

Anonymous    Jan 01, 2006
Printed
Page 216
line 1 of the exercises

Change the phrase

"See Appendix Q"

to be instead

"See Appendix A"

Since there is more than one exercise, please change the phrase

"to the following exercise:"

to be instead

"to the following exercises:"

Anonymous   
Printed
Page 230,232,242,252
bottom left label

Appendix 1: Exercise Answers
->
Appendix A: Exercise Answers

#######################################

Anonymous    Jan 01, 2007
Printed
Page 230, 231
5th line from the top; the exercise answers were missing numbers and/or incorrectly numbered.

Page 230,5th line from the top;
"Here's one way to do it:" NOW READS "2. Here's one way to do it:".

(exercise 2 answer, first line)
"2. Here's one way to do it:" NOW READS "3. Here's one way to do it:".

Page 231:(first line of page)
"Here's one way to do it:" NOW READS "4. Here's one way to do it:".

(exercise 3 answer, first line)
"3. Here's one way to do it:" NOW READS "5. Here's one way to do it:".

Anonymous    Apr 01, 2006
Printed
Page 232
Six lines above "Answers to Chapter 4 Exercises"

"Here's one way to do it" NOW READS "3. Here's one way to do it".

Anonymous    Apr 01, 2006
Printed
Page 234
Exercise answer

The code stating at the top of the page should read

foreach my $element (@_)


Anonymous   
Printed
Page 235
The paragraph beginning "Here's one way to do it:"

Here's one way...
->
3. Here's one way...

#######################################

Anonymous    Jan 01, 2007
Printed
Page 240-241
Exercise 9-1; first code block on page 241, 2nd line

unless (defined $in)
->
if ( not defined $in )

#######################################

Anonymous    May 01, 2007
Printed
Page 240
Part 5.

The pattern of /s+$/ appears to have an unnecessary +. Since the pattern is searching for a whitespace character at the end of the line, it is unimportant whether or not there are multiple whitespace characters, especially since nothing is being put into memory.

Note from the Author or Editor:
Since we chomped, we don't expect a newline at the end so we can look for just /\s$/

Anonymous   
Printed
Page 241
Exercise numbering, line 5

"Here's one way to do it:"

NOW READS:
"2. Here's one way to do it:"

and the rest of the exercise answers HAVE BEEN RENUMBERED so that 2 is really 3, 3 is really 4, and
4 is really 5.

Anonymous    Jan 01, 2006
Printed
Page 241
Answers to exercise 9.4 changed to

while (<>) {
if (/^#!/) {
$_ .= "## Copyright (C) 2006 by Yours Truly!
";
}
print $_;
}

#######################################

Anonymous    May 01, 2007
Printed
Page 241
2nd paragraph, in second line of code for answer to #2

This is a chapter 9 exercise. The solution mentions the control structure 'unless', but this
isn't introduced until chapter 10.

Note from the Author or Editor:
Okay, fixed in the next edition. Otherwise, use

if( ! ... ) { ... }

Anonymous   
Printed
Page 242
in the fifth exercise, in the last code fragment

the print statement was previously missing. The code fragment NOW READS:

@ARGV = sort keys $do_these;
$^I = ".bak"; # make backups
while (<>) {
if (/^#!/) { # is it the shebang line?
$_ .= "## Copyright (c) 20XX by Yours Truly
";
}
print;
}

Anonymous    Jan 01, 2006
Printed
Page 243
footnote

The website in the footnote is wrong. Change

http://www.cpan.org/doc/FMTEYEWTK/random

to be instead

http://www.perl.com/doc/FMTEYEWTK/random

Note from the Author or Editor:
Change as noted

Anonymous   
Printed
Page 247
exercises 5, 6, and 7 solution

The solution code used for chapter 12, exercise 5, makes use of modules that have not been covered in the chapter (nor in the book up to this chapter). Modules File::Basename and File::Spec are covered later in the book in Chapter 15 and Appendix B.


Anonymous   
Printed
Page 250
line 25

Change the phrase

"in this case with last)."

to

"in this case with last.)"

In other words, the period and the parenthesis should be reversed.

Anonymous   
Printed
Page 251
paragraph 2; sentence beginning "On the other hand..."

if you were wanted to obfuscate your code..."
->
if you wanted to obfuscate your code...

#######################################

Anonymous    Jan 01, 2007
Printed
Page 252-253
Answers to Chapter 15 exercises

The solutions to these exercises previously contained references to modules and Perl code all within "C<" and ">"
formatting characters.

Those formatting characters HAVE BEEN REMOVED.

Anonymous    Jan 01, 2006
Printed
Page 252
Heading for Chapter 15 exercises

Change the heading for Chapter 15 exercises from

"Answer to Chapter 15 Exercise"

to

"Answer to Chapter 15 Exercises"

(i.e., the word "exercise" should be plural.)

Anonymous   
Printed
Page 252
last line of Chapter 15, exercise 1

Change

"details later.)"

to

"details later)."

In other words, the parenthesis and the period are in the wrong order. The period should be outside the parenthesis, because the period is ending the outside sentence "This answer uses a hash reference"

Anonymous