Intermediate Perl by Randal L. Schwartz, brian d foy, Tom Phoenix The unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification This page was updated July 29, 2008. UNCONFIRMED errors and comments from readers: {20} Exercise 2; [10/07] Printing Also p. 223 Exercise 2 (Answers) There is no country_code method in Business::ISBN v 2.03. (80) 4th paragraph, not including code blocks; In the 10/07 printing, it currently reads: '...Perl tries to use the value in C<$log_fh> as a symbolic reference, so it tries to print to the filehandle named C<5>. Under C, this is a fatal error.' The 'C<...>' text is in a larger monospace font never before used before in the book. I saw a note about this in errata for the most recent printing saying to *add* this sentence. I'm guessing they meant that C signifies that 'alpha' should be formatted as code. {83} First code example in 'Anonymous IO::File Objects'; The arguments to the calls to IO::File->new are single-quoted strings but the strings contain references to $file and $out. I'm guessing interpolation was expected, in which case the strings should be double-quoted. {84} Second code example; defined($line = and print $OUT $line; should read defined($line = <$IN> and print $OUT $line; {85} First code example under IO::Tee; The first open statement: or die "Could not open castaways.log; should read or die "Could not open castaways.log" [86] Top half of page, 1st code example folowwing paragraph beginning: "That's not all"; The last statement, "print," causes a warning that says the filehandle is opened for input only. It also causes an additional and unwanted output operation to the intended output files because the output is first accomplished via the preceding line: my $message = <$tee_fh>; This is consistent with the documentation for the IO:Tee module at the end of the paragraph beginning with, "The second way." {91} Last paragraph; "Professor is position 2" should read, "Professor is position 3" {99} code after 1st paragraph; [10/07] printing my %directory = %$data; is unnecessary. Also, 3rd line later: dump_data_for_path("$path/$_", $data->{$_}); Exercises Ch. 9 #4 pp 232-233, similar changes {132} First code example inside paragraph starting "Let's make a sheep"; my $lost = bless { Name => 'Bo', Color => 'white' }, Sheep; should read my $lost = bless { Name => 'Bo', Color => 'white' }, 'Sheep'; {137} 4th line of the first paragraph; "setter became a getter" should read "getter became a setter" [161] first paragraph; All references to subclasses should be turn to superclasses. You don't inherit from subclasses. {221}first exercise; Code sample generates one warning and one error if run with perl -w. The problem is with the file test. #!/usr/bin/perl my @smaller_than_1000 = grep { -s < 1000 } @ARGV; print map { " $_\n" } @smaller_than_1000; the -s < is ambiguous to the interpreter, so fails when the interpreter tries to resolve < to the first part of a diamond operator. grep { (-s) < 1000 } @ARGV; # works grep { 1000 > -s } @ARGV; # also works The same applies for the one-liner 2nd example: print map { " $_\n" } grep { -s < 1000 } @ARGV; [229] code at top of page; Have no idea of what slick Perl trick they're trying to do, but it's not legal Perl according to my 5.8.7 interpreter in Cygwin. The code in question begins with print $fh <<"HERE" and ends at the second HERE, 9 lines down in the second block of code. I'm guessing this was supposed to be a string concatenated across several lines, but there are no quotes surrounding this text. [223] only code sample in paragraph, Answers for ch 3, exercise 2; It seems like as of Business::ISBN 2.03 that 'country_code' is not longer supported. [231] 4th line of code listing; while( my $file = $dh->read ) { should read while( defined(my $file = $dh-> read) ) { Otherwise the while can potentially abort prematurely atleast for the case where there is a file named '0' in the directory. [231] Exercise 2; The code of Exercise 2 is not correct. The Ordinary "is" still faster. The solution was in the comments to the quoted URL: http://www.perlmonks.com/?node_id=393128 The @files is not known to Benchmark. With the code on p 231 the Ordinary is still faster, but @files is empty. Probably most clear is to change the q{} to sub {} in the code for the Ordinary and Schwartzian. Running with the q{} quoted code of the example: Benchmark: running Ordinary, Schwartzian for at least 2 CPU seconds... Ordinary: 2 wallclock secs ( 2.03 usr + 0.00 sys = 2.03 CPU) @ 398461.58/s (n=808877) Schwartzian: 3 wallclock secs ( 2.04 usr + 0.03 sys = 2.07 CPU) @ 337243.48/s (n=698094) Changing q{} to sub {} shows the following results Running with the sub on /etc/* (81 files): Benchmark: running Ordinary, Schwartzian for at least 2 CPU seconds... Ordinary: 3 wallclock secs ( 0.38 usr + 1.73 sys = 2.11 CPU) @ 58.77/s (n=124) Schwartzian: 2 wallclock secs ( 1.21 usr + 0.84 sys = 2.05 CPU) @ 214.63/s (n=440) Running with the sub on /bin/* (81 files): Benchmark: running Ordinary, Schwartzian for at least 2 CPU seconds... Ordinary: 3 wallclock secs ( 0.35 usr + 1.66 sys = 2.01 CPU) @ 129.85/s (n=261) Schwartzian: 2 wallclock secs ( 1.12 usr + 1.00 sys = 2.12 CPU) @ 416.98/s (n=884) This is perl, v5.8.6 built for darwin-thread-multi-2level on Mac OS X 10.4.9 G3 500 MHz. [241] Exer 2 solution; locatime needs to be localtime() [244] 3rd paragraph and code below it; The text mentions making a copy of the array. In the code below the reference is copied. Both $array and $shuffled therefore still point to the same data. The test will not work. {245} Code; use Exporter is redundant, use base qw(Exporter) already takes care of that.