Perl Cookbook by Tom Christiansen & Nathan Torkington Here are the changes made in the 12/00 reprint: (xxviii) Knuth's "The Art of Computer Programming" now says 3rd Edition, 1998. (37) 1st paragraph: Reference to Recipe 16.14 (installing an output filter) was changed to Recipe 16.5. {71} table listing the time fuction variables: "1-366" now reads "0-365." (73) first paragraph "YYYY-MM-DD," now reads "YYYY MM DD", {80} 2nd program block example, first line, missing semicolon: terminating semicolon missing in example; as shown, recipe will abort. was: use Date:Calc qw(Day_of_Week Week_Number Day_of_Week_to_Text) ^ now reads: use Date:Calc qw(Day_of_Week Week_Number Day_of_Week_to_Text); [81] 1st code block: The timelocal function expects months to be in a 0 based format (i.e. 0 = Jan). In the example given, the date "1998-06-03" is parsed and sent as is to timelocal(). The month value ("03") should be decremented by 1 before being passed to timelocal(). now reads: $epoch_seconds = timelocal(0, 0, 0, $dd, $mm-1, $yyyy-1900); {84} code now reads: first chunk: use Time::HiRes; $t0 = Time::HiRes::time; ## do your operation here $t1 = Time::HiRes::time; $elapsed = $t1 - $t0; # $elapsed is a floating point value, representing number # of seconds between $t1 and $t2 second chunk: use Time::HiRes; print "Press Return when ready: "; $before = Time::HiRes::time(); $line = <>; $elapsed = Time::HiRes::time() - $before; print "You took $elapsed seconds.\n"; Press return when ready: You took 0.228149 seconds. (126) 4th paragraph: now reads: You call n2perm with two arguments: the permutation number to generate (from 0 through factorial(N)-1, where N is the size of your array) and the subscript of the array's last element. (165) 5th paragraph: In the code before the "See Also" block, the first line now read ($a = $b) =~ s/x/y/g; # copy $b to $a, then change $b [172] 3rd para: The correct text now reads: When you want the last match of arbitrary pattern A, you find A followed by any number of characters not followed by A. The general construct is A(?!.*A), which can be broken up for legibility: m{ A # find some pattern A (?! # mustn't be able to find .* # something A # and A ) }x {255} line 7: % cc -o fionread fionread now reads % cc -o fionread fionread.c {284} last code: $data = '/usr/share/games/fortunes'; now reads @ARGV = qw( /usr/share/games/fortunes ); {295} line 4 from bottom: ... $time, $line, $time); now reads ... $time, $line, $host); {304} line 10 of middle code: The while statement was left-shifted one tabstop. {307} line -7: "sizeofor" now reads "sizeof or". {307} line -8 "die" now reads "warn." (312) -2.2: "change directory" now reads "change the directory." (Sounded too much like chdir as written). (315) footnote: "...by the owner" now reads "...by the file's owner." (322) 1st line: "file;" now reads "filename;". {330} 1.17: 07777 now reads 0777. {330} 1.23: chdir $srcdir; now reads chdir $srcdir or die "Can't chdir to $srcdir: $!"; {333} subroutine definitions for user and group: the line $user{$uid} = getpwuid($uid)->name || "#$uid" now reads $user{$uid} = getpwuid($uid) ? getpwuid($uid)->name : "#$uid" Likewise, the line $group{$gid} = getgrgid($gid)->name || "#$gid" now reads $group{$gid} = getgrgid($gid) ? getgrgid($gid)->name : "#$gid" {403} BEGIN { unless (eval "use $mod") { warn "couldn't load $mod: $@"; } } now reads BEGIN { eval "use $mod"; if ($@) { warn "$@"} } {430} -1.7: FineTime.ccc now reads Finetime.c && cc Also, "FineTime.c" in "FineTime.cRunning" was moved to the previous line. (435) last code comment: "have your own a" now reads "have your own". [510] "See Also" section: This URL is out of date: http://www.hermetica.com/technologia/perl/DBI/ The current location of the documents formerly found there now reads: http://www.symbolstone.org/technology/perl/DBI/ [556] 5th paragraph: "(but not backticks)" was removed. [617] under "Discussion" concerning UNIX Domain Datagram Server: The variable LocalAddr was changed to Local and PeerAddr was changed to Peer. {618} If you want its actual host name: use Socket; $other_end = getpeername(SOCKET) or die "Couldn't identify other end: $!\n"; ($port, $iaddr) = unpack_sockaddr_in($other_end); $actual_ip = inet_ntoa($iaddr); $claimed_hostname = gethostbyaddr($iaddr, AF_INET); @name_lookup = gethostbyname($claimed_hostname) or die "Could not look up $claimed_hostname : $!\n"; @resolved_ips = map { inet_ntoa($_) } @ips_for_hostname[ 4 .. $#ips_for_hostname ]; But look at the misconnect between the variables used in the last two lines! They now read: @name_lookup = gethostbyname($claimed_hostname) or die "Could not look up $claimed_hostname : $!\n"; @resolved_ips = map { inet_ntoa($_) } @name_lookup[ 4 .. $#name_lookup ]; (658) 2nd paragraph: The example coded now reads: $undeleted = $pop->list(); foreach $msgnum (keys %$undeleted) { $msgsize = $undeleted->{$msgnum}; print "Message $msgnum is $msgsize bytes long.\n"; } (716) third paragraph now reads: A correct but slower and slightly more complicated way is to use the HTML-Tree bundle of modules from CPAN: