Author's Errata for Mastering Perl/Tk, First Edition

As I discover errors or they filter into the O'Reilly errata page, I make updates here. Typically, this page always has the most up-to-date corrections, since I have a daily cron job that polls the O'Reilly errata page and informs me of changes.

Steve Lidie

Last Updated : 2003/12/20

Unconfirmed Errors and Comments

These items are from the O'Reilly Unconfirmed Errata page and are incorrect; that is, Mastering Perl/Tk is correct as written.

(None at this time.)

Confirmed Errors and Comments

These items are from the O'Reilly Unconfirmed Errata page and are deemed correct; that is, Mastering Perl/Tk is in error as written. Periodically, O'Reilly takes this information and moves it to their Confirmed Errata page.

(xiv) In the footnote: Laundry list should also contain "references".

(23) first line; missing the trailing quote mark on the fourth -side option, 'bottom'.

{32} lines 4-5; "which widget should be placed after your new widget." => "which widget your new widget should be placed after."

{38} $i = 0; - this variable is never used.

{39} In the listing: lines 24 (my $b =...) to 26 ($b->packForget;) are useless and should be removed.

{40} In the listing: last lines in procedure "addwidget" ($top->Button(...): the pack option "-anchor => $anchordirs[$count]" is missing.

(40) Last paragraph: "This sample" -> "The next example" is more clear.

{68} last if statement in example code; if ($rightspring ne '') { push (@args, ('-rightspring', $rightspring)); } should be if ($leftspring ne '') { push (@args, ('-leftspring', $leftspring)); }

(71) 6th paragraph; "you programs." => "your programs."

[76] The dynamic font viewing program fails to properly account for fonts with embedded spaces. It tries to use tags whose values are the font name, but it's illegal to have tags with spaces, so a second variable is required that is the font name minus embeded spaces. The corrected program is available from my always the most recent examples tar file.

{86} In table, entry -relief: "Default for Button is 'raised'." is missing.

{90} In last paragraph of section: "Using -relief with -indicator => 0 is..." should read "... -indicatoron => 0 ...".

{95}In the listing: line 13 "$_->pack('forget')" should be "$->packForget".

[96] Example of disabling a Button, use cget() rather than configure() to fetch an option value. So, change it to read my $state = $exit_b->cget(-state);.

{113} -foreground option refers to a Button widget, but it should be Label.

{116} In the sample code: "-textvariable => $message,)" remove the trailing comma.

(117) 2nd and 3rd line of "The Entry Widget"; the "-" sign at the end of line belongs to "command" at the beginning of the next line; shouldn't be separated.

(119) 'active' is not a legal value for the -state option.

(131) Above figure 5-15: "In this case, 50% of the text...", 50 must be changed to 20.

(134) First paragraph, Tk::Pane is now part of the Perl/Tk distribution. "If you want a scrollable Frame use Tk::Pane, described in Chapter 23."

(143) Figure 6-12: "80% into data", 80% must be changed to 90%.

{149} 2nd to last paragraph mentions user-contributed "multi-Listbox" widgets. Actually, we do not talk about user contributed wigets, for the reasons discussed in Chapter 23, section "Widgets Not in the Perl/Tk Distribution", page 583.

{149} mentions the TextList widget, which we regrettably fail to explicitly document. Please refer to the section "The Perl/Tk Text Widget Extended Methods" on page 188.

{151} List of options: "-takefocus => 0|1|undef", default "undef" should be bold.

{159} Footnote to last sentence "So , when might we bind to this event?" is on page 160.

(163) List of options, entry "-height": "Sets the height of the widget.", add "in lines of text" for clarification.

{173} -state tag option no longer exists, remove it (use -elide instead).

(177) First line: "... shows a psuedo-link example." Should be "pseudo".

{178} First paragraph, list of bindings: "<F1>Invokes...", Insert space between "<F1>" and "Invokes". (Also for the other lines in that section!)

{183} In the Search Options table, the -hidden option no longer exists, it's called -elide now. The text should now read: -elide Find elidden (hidden) text as well. By default only displayed text is searched.

{195} Figure 9-2: Either "Y = -100" or draw the figure upside down! Actually, the figure needs a total overhaul ...

(197) third paragraph: "... this one small annoyance, bind works just..." "bind" should be "CanvasBind".

{204} -image option; "See Chapter 3" => "See Chapter 17"

{214} The example $c->find('withtag', '(a&&!b)|(!a&&b)') is missing one '|'. It should read $c->find('withtag', '(a&&!b)||(!a&&b)').

{216} Section "Getting Tags from a Specific Item": "If the tag/id doesn't match anything, an empty string is returned." "empty string" should be "empty list".

{217} The bounding box example shows the query result as ($l, $r, $t, $b), which is incorrect. The result is a list of two diagonal coordinates ($x1, $y1, $x2, $y2).

(225) Suggestion: Heading "Scale Options" is missing before the list.

{248} Reference to Fig 11-3 is correct, but the actual figure is missing. Renumber subsequent figures and cross-references. Here's the real Figure 11-3:

{275} In Tk800.023 -variable works differently. In the Optionmenu example, change -variable to -textvariable. For instance, if -options => [[jan=>1], [feb=>2], [mar=>3], [apr=>4]], then -textvariable holds the month string while -variable holds the integer ordinal.

{277-278} Two lines in the native optiomenu program need changing.Interestingly, the sample code is already correct - not sure how this got into the book! On page 277, third line of the program:

    my($parent, $varref, $callback, @optionvals) = @_;

Should be:

    my($parent, $varref, $command, @optionvals) = @_;
On page 278, 19 program lines down: "-command => [$callback, $_]" should be "-command => [@$callback, $_]".

(290) Fourth paragraph: "Note that this is the only widget we know", "widget" should be "widget method".

[300] replace paragraph seven in it's entirety (The order in which the focus moves around matches .... on to the next one (e.g., a Text widget.) with:

"The order in which the focus moves depends on the stacking order of the widgets, as described in the previous section, Focus Methods".

{313}Eight paragraph starting with "Line 20 ... in our sample code ... options => [1..5]", "[1..5]" should be "[1..2]" (the sample on page 311 used "addOptions(3..5)"!).

(324) Caption Figure 14-7: "Smal, purple text". "Smal" should be "Small".

{329} To get the output as shown on the end of the page the code must be changed from "foreach (keys %{..." to "foreach (sort keys %{...".

(346) "solutionand" => "solution, and"

{348} Code line after 3rd paragraph: "ldifference [keys %SHAPE], \@{$LLCD{$_}} ]", $LLCD{$_} is already an array reference, so "\@{...}" should be "$LLCD{$_}".

[355] The "make test" example following the second paragraph, "This automatically creates MANIFEST and for us. Now type this:", should actually be "make dist".

(359) 3rd paragraph (not counting example code and message text); In the sentence that begins "This form us used more often in binding commands" the second "it's" should have no apostrophe.

(361) "know as an event descriptor" => "known as an event descriptor"

(372) In the middle of the code listing, "Which yields:" wrong font (should be normal text) and wrong indentation.

[378] example in section titled "Executing Nonblocking System Commands" - (I wouldn't characterize this a 'serious technical mistake' so much as an 'important caveat', but then, I'm not the sysadmin...)

The method of opening a file handle to a 'tail -f' pipe and waiting for it to become readable with the 'fileevent' method works well (thank you!) -- HOWEVER, on some (most? all?) systems (e.g., Solaris 7) the 'tail' subprocess survives the [normal] termination of the perl program itself. In addition to the obvious matter of spawning immortal processes, this can lead to problems when the file becomes readable and the output file for 'tail' (the aforementioned pipe) no longer exists. (On NFS mounted filesystems, a '.nfs' file is created in the current working directory that only be removed by logging onto the [file]host system to delete it.)

I would suggest that users make sure any 'piped' subprocesses are killed before the file handles are closed. My choice of method is to set the process group id of the current process, allowing me to kill all subprocesses without knowing their process id's explicitly (refer to 'setpgrp', 'kill' commands in 'Programming Perl' book).

You make several great points, which will make it into the next printing of Mastering Perl/Tk. I'll probably just hint at the problems here and point readers to the discussion of the Tk::ExecuteCommand widget, where the problems are already solved.

(393) Third paragraph: "The foreach loop creates the actual watchpoint objects, using our callbacks ...". "callbacks" is possessive, so make that "callback's".

(393) last line: "why waitVariableX is returned" => "why waitVariableX returned".

(394) In the splashscreen pseudo-code, the call to waitVariableX has a leading & character - remove it.

{424} In the section "Cool Tricks with an Empty Bitmap", the use of the term "transparent" was unfortunate. The bitmap is not really transparent, rather, it always takes on the same color as the background, so it's simply invisible. To be really transparent, the value for trans_cur_bits[] in the mask should read "0x00" and not "0x01". As you can see from the example in the previous section, bitmap and mask work like this:

       bitmap    mask     shown color
         0        0       transparent
         1        0       transparent
         0        1       bitmap's -background
         1        1       bitmap's -foreground

So only if all mask bits are set to "0" can the cursor be transparent.

(446) Second paragraph: "Here is the cod that...", "cod" should be "code".

(511) 2nd paragraph, change "get/get" to "get/set".

{543} 2nd paragraph; the name Grant Hopwell should really be Grant Hopwood.

[543] 4th paragraph; The noted module (Win32::MemMap) does not appear to be available from the listed location ( or from CPAN. In addition, the other module required (Tie::Win32MemMap) doesn't appear there or on CPAN. The modules are available either from http://www.Lehigh.EDU/~sol0/ptk/ptk.html or

{569} Add the following sentence to the description of -initialfile: "This value cannot be a path name, but must be a simple filename, which is relative to the initial directory, whether it be the current working directory or the value specified by the -initialdir option."

{575} In the list of options, entry "-choices": "... or -choices => @init_choices", "@init_choices" should be "\@init_choices".

(586) last paragraph; explain how to use PPM through a proxy or firewall:

If you use a proxy server or firewall, PPM may fail. Generally, you can workaround the problem by setting the environment variables HTTP_proxy, HTTP_proxy_user and HTTP_proxy_pass before invoking PPM. If this also fails, you can fetch packages from ActiveState's repository and install them locally. For complete details, see

For example:

SET HTTP_proxy=http://proxy:8080 
SET HTTP_proxy_user=proxyun
SET HTTP_proxy_pass=proxypw

Note: There are many errors in the index. Since O'Reilly has made a corrected index available (see below), I've removed all index errata except those that are not reflected in the new index.

Index, pages 717 - 746

In the first printing of Mastering Perl/Tk (dated January 2002), the index had many errors due to a merge conflict. We include a corrected index both in HTML and in PDF . Please accept our apologies for any inconvenience this has caused you. Future printings of Mastering Perl/Tk will have the corrected index incorporated into the book.

(717) 2nd column, near bottom; Index entry for "after" says page 287, but there is no reference to "after" on that page. Should be pages "305, 357, 389".

(729) Under the "images" index entry "creating 200", change it to "creating 204, 417".

(736) Under the "properties, window manager" index entry, page shows 234, but should be "238, 243".