Errata

Perl for Web Site Management

Errata for Perl for Web Site Management

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
Printed Page 115
Middle of page

Here's the quote from 'Perl for Web Site Management':
"if you put a 'my' declaration on the variable that will hold the current element for
each trip through a 'foreach' loop, the variable's scope extends only from the
declaration to the end of the loop."

Well, this is pretty much the default action of the variable in the foreach loop. As
the Camel book points out, p. 119, "The loop variable is valid only from within the
dynamic or lexical scope of the loop.... In either case, any previous value the
localized variable had before the loop will be restored automatically upon loop
exit."

The real reason for the 'my' declaration in the foreach loop in 'Perl for Web Site
Management' is that Perl would otherwise complain about an error at this point due to
the 'use strict' pragma that is in effect. If 'use strict' had not been previously
called the 'my' declaration would not have been needed to keep the scope to the end
of the block in this example.

Anonymous   
Printed Page 119
1st paragraph

$exhibit{$co_name} should be changed to $listing{$co_name}

Anonymous   
Printed Page 194

- this is about the way rounding error can
(and will) accumulate due to the division in the line

$total_mb += ( $bytes / ( 1024 * 1024 ) );

which is inside a loop going over all the lines in a web log.
The rounding inaccuracies here can be quite large (percentage-wise)
( especially for a website with lots of relatively small files ).

A more accurate ( and also less computationally expensive )
approach is :

for ( each line ) {
.
.
$total_bytes += $bytes ;
.
.
}
$total_mb = $total_bytes / ( 1024 *1024 ) ;

( It's possible that we might want to use $total_bytes as a
BigInt to avoid overflow problems, but that's another story. )

Anonymous