Errata

Perl Hacks

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
Other Digital Version NA
NA

In the code examples available for download, there is a missing semicolon in line 4 of find_pm_files.pl, which is in the subdirectory perl_hacks_examples/productivity_hacks/autocomplete_perl_identifi
ers_in_vim. (I think that the book used to have the same error. It looks like the semicolon was added in the book, but not in the examples.)

In any case, the line should read:

my $LIST_DIR = "$ENV{HOME}/.vim_extras/";

It's easy to fix, but why not make it even easier for us? Thanks.

Anonymous  May 18, 2008 
Printed Page 11
second alias

In cygwin (my version of cygpath was compiled on April 12, 2010) the command

alias winrun='exec 'cmd', "/c", ((split '/',$0)[-1], map { s/^(.*)$/(-f $1)?qx{cygpath -w "$1"}:$1/e;chomp;$_; } (@ARGV));'

doesn't work for me. I get the error

bash: syntax error near unexpected token `('

For one thing, an invocation to perl seems to be missing. I can see in general terms what it's supposed to be doing, but I don't know enough about the shell and cygwin to fix the problem, sorry.

Anonymous  Sep 02, 2010 
Printed Page 17
2nd paragraph

" For Vim 6.2 (compile for OS X Tiger) the mappings each need "!" after
" "map" in order to function as advertised:
map ,pt <Esc>:%! perltidy<CR>
" ^--"!"
map ,ptv <Esc>:'<,'>! perltidy<CR>
" ^--"!"

Anonymous   
Printed Page 36
last line

"Compiling for Mac (New Age)... -> Code for this output is missing in example

Anonymous   
Printed Page 74
last but one paragraph

Hack #30 says that Rails automatically notices when you change a library and reloads it.

What actually happens is that Rails removes everything at the end of each request. It iterates over all reloadable classes and removes their constant unconditionally. It does not check whether the class has been modified.

In the next request classes are reloaded because the constant is no longer there, as in the initial request.

The implementation changed in 1.2, but that's still how it works.

Anonymous   
Printed Page 88
3rd code example + final paragraph

Code reads:

package Parser;
sub subs 'exit';
package main;

use Parser;
sub Parser::exit{die shift;}

Final paragraph reads:

Back in the main package, the odd-looking subroutine declaration...

What odd looking subroutine declaration? And I suspect it's important so 'exit' works in other packages outside Parser.

Anonymous   
Printed Page 99
footnote

To be able to do the "fink install" packages marked as "unstable"
have to be added to Fink's index, otherwise the installation will fail.

Anonymous   
Printed Page 114
code example, 7th line from bottom

Without "no warnings 'misc';" the warning "Undefined value assigned to typeglob."
will be shown twice. Maybe this behaviour is wanted - maybe not.

Anonymous   
Printed Page 138
code example, line 7

"split /s*,?s*/, $call;" ->
"split /s*,s*/, $call;"
Unless this is wanted?

Anonymous   
Printed Page 143
code example, line 3

"sub divide_by" appears to be misleading since it implies division _by_ the given
argument. Actually it is the argument itself being divided.

Anonymous   
Printed Page 149
"Hacking the Hack", code example, line 1

To make this work, the module should either be loaded from within .perldb
("use Devel::Command;") or on the command line as
flatbox ~ $ perl -MDevel::Command -de0

Anonymous   
Printed Page 154
last paragraph, 1st sentence

Interesting bug here. If "sub gives_error" is defined _after_ the two properties
the second test will fail. This has probably to do with the usage of the
source filter Filter::Util::Call in Test::LectroTest.

Anonymous   
Printed Page 157
1st paragraph

The example code does not work because perl is confused by the angle-brackets (<>). Error-message is: readline() on unopened filehandle

Wrong code:
my $test_pattern = catfile(qw( t developer *.t ) );
push @$tests, <$test_pattern>;

Working code:
my $test_pattern = catfile(qw( t developer *.t ) );
push @$tests, glob($test_pattern);

---------- Version Info -------------
$ perl -v

This is perl, v5.10.0 built for darwin-thread-multi-2level
(with 4 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1004 [287188] provided by ActiveState http://www.ActiveState.com
Built Sep 3 2008 12:31:57

IngoLantschner  Jul 24, 2009 
Printed Page 157
Last paragraph of "Running the Hack"

Proposed invocation does not fit to code on page 156 (confusion singular/plural).

Wrong invocation:
perl ./Build disttests

Working invocation:
perl ./Build disttest

IngoLantschner  Jul 24, 2009 
Printed Page 167
4th paragraph,

..., pass the -Doptimize='g' flag.

->

..., pass the -Doptimize='-g' flag.

Hexcoder  Apr 01, 2010 
Printed Page 258
1st paragraph

The text states that unary operations are applied to both ends of the interval, and puts sqrt() as example. That's true for sqrt() because it is monotone increasing, but as explained in the hack the reader could think the same procedure applies to any function, which is not the case.

You can happily work with interval ends as long as the function is monotone in that range (reversing them if it decreasing), but you cannot apply a unary operation and obtain something that contains the image of the actual value without some restriction on the function. Think sin().

Anonymous