Mastering Perl

Errata for Mastering Perl

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
ePub Page 40
Listing of

The listing of is supposed to show Michael Carman's regex as mentioned in the text above and seen in the debugger output following it. What is actually shown is the "faulty" version:

$money =~ s/(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)/,/g; # $1,234.5678

which leads to $1,234.56,789 for the input $1234.56789 (so yes, the comment is also missing a '9' at the end). Instead, this line should read

$money =~ s/(?<!\.)(?:\b|\G)\d+?\K(?=(?:\d\d\d)+\b)/,/g; # $1,234.56789

The mistake is also in the files from the download section on the book website.

Benjamin W├╝thrich  Jul 12, 2015