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.
Version |
Location |
Description |
Submitted By |
Date submitted |
Date corrected |
PDF |
Page 10
1st bunch of code |
my $regex = eval { qr/$pattern/ };
die "Check your pattern! $@" if $@;
while( <> ) {
if( m/$regex/ ) {
print "$_";
print "\t\t\$&: ",
substr( $_, $-[$i], $+[$i] - $-[$i] ), ## Error
"\n";
foreach my $i ( 1 .. $#- ) {
print "\t\t\$$i: ",
substr( $_, $-[$i], $+[$i] - $-[$i] ),
"\n";
}
}
}
## The first substr line is invalid. $i is not even initialized.
Note from the Author or Editor: Change that line to
substr( $_, $-[0], $+[0] - $-[0] ),
|
Anonymous |
Jan 04, 2011 |
|
PDF |
Page 24
2nd paragraph |
"The positive lookbehind assertion also looks backward, but its pattern must not match."
It should match
Note from the Author or Editor: Change as noted
|
Anonymous |
Jan 04, 2011 |
|
Printed |
Page 25
Lookarounds |
The regular expression that adds commas to numbers don't work.
$_ = '$1234.56789';
s/(?<!.d)(?<=d)(?=(?:ddd)+)/,/g;
will yield '$1,234.56,789'.
Note from the Author or Editor: The example is just wrong and there's not a pleasing way to fix it.
|
Anonymous |
|
|
Printed |
Page 28
Final Thoughts |
m/[:alpha:]/ should be m/[[:alpha:]]/, and so on.
Otherwise, m/[:alpha:]/ matches a character from the class {:,a,l,p,h,a,:}.
Note from the Author or Editor: Change as noted
|
Anonymous |
|
|
|
30
first examples of section "final thoughts" |
Examples such as:
print "Didn't find spaces!\n" if $string =~ m/[:^space:]/;
don't do what the text suggests. Not finding spaces is not the same as finding non-spaces. There are four occurences of this (two with [:^, two with \P).
Note from the Author or Editor: Those lines should read:
I negate those with a caret, C<^>, after the first colon:
print "Found non-alphabetics!\n" if $string =~ m/[[:^alpha:]]/;
print "Found non-spaces!\n" if $string =~ m/[[:^space:]]/;
I can say the same thing in another way by specifying a named property.
The C<\p{Name}> sequence (little p) includes the characters for the named
property, and the C<\P{Name}> sequence (big P} is its complement:
print "Found ASCII character!\n" if $string =~ m/\p{IsASCII}/;
print "Found control characters!\n" if $string =~ m/\p{IsCntrl}/;
print "Found non-punctuation characters!\n" if $string =~ m/\P{IsPunct}/;
print "Found non-uppercase characters!\n" if $string =~ m/\P{IsUpper}/;
|
Manuel P?gouri?-Gonnard |
Aug 27, 2010 |
|
PDF |
Page 36
Tainted Data |
$ perl tainted-args.pl
Argument [foo] is tainted
## Should be $ perl -T tainted-args.pl foo
Note from the Author or Editor: Change as noted
|
Anonymous |
Jan 04, 2011 |
|
Printed |
Page 42
Fifth paragraph (second from end) |
The inline code $arg[0] should be $args[0]
Note from the Author or Editor: Change as noted
|
Anonymous |
|
|
Printed |
Page 44
second code example |
The code line reads:
setuid( $<, $< )
but should be
setuid( $< );
Note from the Author or Editor: Change as noted.
|
Anonymous |
|
|
Printed |
Page 48
second to last code example |
The code line reads:
The value of var before is [$var] at program.pl line 123
That is sample output and the double string interpolation will have filled in $var with its
value. Since I don't give $var a value in the example, note that with three dots:
The value of var before is [...] at program.pl line 123
Note from the Author or Editor: Change as noted
|
Anonymous |
|
|
Printed |
Page 131
Missing text before section "Typeglobs" |
The section "The Symbol Table", in a nutshell, explains how the set of package variables can be
accessed in a hash-like fashion, and features an example showing the strong association between
the two: creating variables causes them to appear in the hash-like structure.
The last step of the example (starting middle of page 130) shows "I can delete all the variables
with the same name", using the delete operator. The output of the example does indeed show that
the result is the removal of the variables *n and *m from the symbol table for package Foo, but
it also shows that the variables themselves are not gone -- $n and $m still have their previous
values.
I was expecting that the variables themselves would cease to exist. The example output is
_correct_ in that the variables are gone from the symbol table yet still exist when referenced
by name, so maybe my expectations are just wrong. But...
Since the section is showing the correlation between variables and the symbol table, ending it
with no explanation of the discrepancy illustrated by the final example left me hanging and
confused. An extra paragraph would be helpful here.
Note from the Author or Editor: Variables are just names that we use in source code to refer to values. Although a variable name might disappear at runtime, the values don't necessarily disappear. Once Perl know which value it's using, the name doesn't matter.
|
Anonymous |
|
|
Printed |
Page 320
Index: Perl Best Practices |
Perl Best Practices is also mentioned on page 118.
Note from the Author or Editor: Update index entry for Perl Best Practices to include page 118
|
Anonymous |
Nov 20, 2008 |
|