Errata

Learning Perl Student Workbook

Errata for Learning Perl Student Workbook

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
PDF, Page cSfyRIYyYXdSJswFBz
aoAAHkiAcHpHO

peMhkP <a href="http://wklojudfeoyl.com/">wklojudfeoyl</a>, [url=http://zvrobxtekiai.com/]zvrobxtekiai[/url], [link=http://unlaxrhwtpez.com/]unlaxrhwtpez[/link], http://hdphgeaqhmvu.com/

xxlodvred  Dec 01, 2016 
PDF Page 27
Exercise 12.5

This is minor typo. The / character should be replace by @, because the exercise is meant for symbolic links, not directories.

Grzegorz Szpetkowski  Aug 05, 2016 
PDF Page 56
8th line of Answer 3.2

The name of variable is written as $last instead of $last_line:

"then update the values of $second_to_last and $last inside the loop block"

Grzegorz Szpetkowski  Jul 28, 2016 
PDF Page 66
5th line of code

It looks like that plain '-' cannot be used for open as the answer presents. The following, simplified code would die with "No such file or directory" message:

my $file = '-';
open my $fh, '<', $file or die "Can't open file: $!";

The basic remedy would be exclude '-' from @ARGV and handle it separately by STDIN filehandle, but there may be some better way.

Grzegorz Szpetkowski  Jul 29, 2016 
PDF Page 99
2nd paragraph

This is minor issue. The each on array in covered in Learning Perl (in arrays chapter), at least starting from 6th edition:

"Perl 5.12 offers another interesting way to handle this, although we didn’t cover it in Learning Perl."

Grzegorz Szpetkowski  Aug 02, 2016 
PDF Page 100
last paragraph

Minor nitpick. The facilities used in this one-liner are covered in Chapter 9 (at the end), especially the -n switch, which means while(<>) with empty body.

Grzegorz Szpetkowski  Aug 02, 2016 
PDF Page 102
last line of first code example

This is small typo. The variable is $. (with dot), but the say statement is using $, (i.e. with comma), which is a different thing.

Grzegorz Szpetkowski  Aug 05, 2016 
PDF Page 119
code sample

The given solution does not compile, with post mortem as:

Global symbol "$wanted_sub" requires explicit package name at my_program line 22.
Global symbol "$hashes_sub" requires explicit package name at my_program line 23.
Missing right curly or square bracket at my_program line 34, at end of line
syntax error at my_program line 34, at EOF
Execution of my_program aborted due to compilation errors.

I am not sure what was the intent of wanted subroutine inside the do block. This is confusing. The working code may look like:

my( $wanted_sub, $hashes_sub ) = do {
my( $file_count, $directory_count, $link_count );

$file_count->{label} = 'file';
$directory_count->{label} = 'directory';
$link_count->{label} = 'link';

sub {
my $full_path = $File::Find::name;
my $dirname = dirname( $full_path );

$file_count->{dirs}{ $dirname }++ if -f $full_path;
$directory_count->{dirs}{ $dirname }++ if -d $full_path;
$link_count->{dirs}{ $dirname }++ if -l $full_path;
},
sub { ( $file_count, $directory_count, $link_count ) };
};

find( $wanted_sub, @ARGV );

The scope of do encapsulates the hashref, while returning both subs in list context. I believe it is exactly what was intended by author.

Grzegorz Szpetkowski  Aug 05, 2016 
PDF Page 141
second snippet of 16.7

This is minor issue. The following line using statement modifier unless:

$sum++ unless /e/;

shall be phrases with if modifier:

$sum++ if /e/;

Grzegorz Szpetkowski  Aug 08, 2016 
PDF Page 144
code listing for Answer 17.2

The Try::Tiny module sets $_ in the catch clause, thus the following line:

say "Could not use regular expression: $@";

should be replaced with:

say "Could not use regular expression: $_";

Grzegorz Szpetkowski  Dec 23, 2016