Advanced Perl Programming by Sriram Srinivasam Here are the changes made in the 2/00 reprint: (xiv) para. -1, line 2: changed "Guido Van Rossum" to "Guido van Rossum" (xiv) At the top, did read: http://www.sunlabs.com/people/john.ousterhout now reads: http://www.scriptics.com/people/john.ousterhout/ {xxii} Clay Irving's Perl Reference web site has a new home at http://reference.perl.com/ . Also added updated contact info to "We'd Like to Hear From You" section. (xxiii) Moved the second-to-last para ("To all my friends ...") to the end, as, "Finally, to all my friends, ...." Also added comma after "encouraging words" {5} last code example, line 4: changed "[$i]" to "[1]" (10) First code example: Changed comment to: # Call GetNextLine 100 times, and time it. (11) Second code example from below.: Changed comment in 3rd line to: # reference to a reference to $a's value {29} first Code after "Representation": Changed Name "Garibaldi" to "E. F. Schumacher" {31} example 2-4, line 12 changed for $j ($i .. $#{$rl_courses}) { to for $j ($i+1 .. $#{$rl_courses}) { {33} First line of code: ... die "Could not open database: $:"; Changed "$:" to "$!" (37) Resources: #1 http site now reads: Available at http://language.perl.com/info/documentation.html (39) In Figure 3.1, Changed the symbol table entry from "Foo::" to "spud" {47} The sample code fragment contained two comments erroneously referring to '$&rs()' now reads '&$rs()' {53} line 7: changed $rsub->(10); to $rs->(10); (55) para after first code block.: changed "INT is a reserved string and" to "INT is a special string that" (55) Last para, line 5: Changed "crash the system" to "crash the program" (56) "Expression Plotting" is now a B-Head (56) 2nd line before Closures: changed "...procedures;" to "...procedure" (56) 2nd line after Closures: changed "...any other ways" to "...any other way" [63] example before heading "Closures Versus Objects": changed "$random_iter1()" and "$random_iter2()" to "&$random_iter1()" and "&$random_iter2()" (69) The first piece of code: Added quote at end of comment "Illegal division ...." (69) Last para, last line: "eval" is now in Courier. {75} 2nd para from bottom: changed If @patterns contains the three strings "^abc", "ghi", "efg$", to If @patterns contains the three strings "^foo", "bar$", "ghi", {89} Last code block: changed "Create a variable subroutine and subroutine..." to "Create a variable and a subroutine..." (93) last line: changed "The double colon gets translated to a filename" to "The double colon gets translated to a pathname" (100) Line 3: "Nicklaus" is now "Niklaus" (103) Line 5: "Not" is now "Note" (103) paragraph after first code block: changed "of the an object" to "of a class" (106) Para after second code block: changed "it is the Regular-Employee" to "it is RegularEmployee" <106> In para. 5, sentences 1 and 2 did read: Both the :: and -> notations are in fact permissible, unlike in C++. The first one is more flexible because Perl figures out the class at run time, while the latter is faster because the function to be called is known at compile time." now read: Both the -> and :: notations are in fact permissible, unlike in C++. (deleted sentence 2) {108} First code line: "$record" is now "$details" (116) Last para: changed "design is to use case analysis" to "design is to use Use Case Analysis" {118} line 14 (from the bottom) changed : $obj->{_price} - $obj->_rebate} to : $obj->{_price} - $obj->{_rebate} {120} para about Tcl, last sentence: "incr Tcl" is now "[incr Tcl]" {125} #2: line -2 of code: changed $r_employee->position... to $emp->position... {126} "'J'Joe'" is now "'Joe'" {127} 2nd line under figure: "@free" is now "@_free" {127} next to last line on page: "@color" is now "@_color" {128} First line of text after code: "@_ATTRIBUTES" is now "@_ATTRIBUTES_" {130} Code at top of page: second line: now reads: # Or, $obj->set_attributes (['age', 'name'], [23, "sriram"]) sub set_attributes { [131] line 8 of first code example: changed local(*attributes) = *{"${pkg}::_ATTRIBUTES_"}; to local (@attributes) = get_attribute_names($pkg); (159) Para after "Record-Oriented Approach": changed "DBM is a disk-based hash table" to "DBM is a disk-based hash table library" (162) Second para after first code block: "$DBI::err" and "$DBI::errstr" are now typeset in Courier. {162} Last piece of code: changed $sth = $dbh->prepare('insert into emptable (name, age) values (? , ?)';); to $sth = $dbh->prepare('insert into emptable (id, name, age) values (?, ? , ?)';); (162) changed: http://www.hermetica.com/technologia/DBI/ to http://www.symbolstone.org/technology/perl/index.html {171} Code after figure 11-1, line 5 and 9: changed @ATTRIBUTES = qw(....); to attributes qw(....); {171} Code at the bottom of page: changed [Employee] attributes = _id, name, age, ... to %g_attr_names = ( "Employee" => [qw(name age)] "Department" => [qw(name address)] ); (175) 3rd line from bottom: Changed "get/set_attributes" to "{get,set}_attributes" (181) 3rd para, last line: "Retrieving Objects" is now a heading. (193) code line 4: changed ... Proto => 'tcp', to ... Proto => 'tcp' {193} code line 9, after print $sock "Msg $_ : How are you?\n"; inserted the line $sock->flush(); {193} Section "Sender", last line: Changed "sending ports" to "sending sockets" (194) Fourth para: Changed "a specified socket" to "any socket" {194} #3: Changed "Make these calls nonblocking" to "Make these sockets nonblocking" {194} line 10 of code: Changed "unless ($sock)" to "unless ($main_sock)" {196} last code, lines 8 and 9: changed ($new_readable) = IO:Select->select($readable_handles, undef, undef, 0); to ($new_readable) = IO:Select->select($readable_handles, undef, undef, undef); {196} last code, line 11: Changed "to read from or write to" to "to read from" {208} list of attributes, description of "sock" is now: "The socket object (of the class IO::Socket::INET class)" {208} Last entry in list: changed "and bytes_to_read contains the bytes still expected" to "and bytes_to_read contains the number of bytes still expected" {212} line 10 of code: changed $offset = length($msg) - 1; to $offset = length($msg); {213} first paragraph, first word: changed "_read" to "_rcv" {217} Code under comment "Server stuff", and again at bottom of page. changed RPC->new_rpc_server to RPC->new_server (233) lines 2-3: "Guido Von Rossum" is now "Guide van Rossum" {233} Section "Inserting text at absolute positions": "column 5" is now "column 6". [233,234] All code snippets involving insert(): The insert method on the text widget requires the index to be the first parameter and then the text. The code examples illustrating insert show the first and second parameters in the reverse order. So, each of these lines did read: $t->insert ("Sample", "2.5") $t->insert ("Sample", "end") $t->insert ("Sample", "insert + 5") $t->insert ("Sample", "insert linestart") $t->insert('Sample', '3.5', 'foo'); and now reads: $t->insert ("2.5", "Sample") $t->insert ("end", "Sample") $t->insert ("insert + 5", "Sample") $t->insert ("insert linestart", "Sample") $t->insert('3.5', 'Sample', 'foo'); {234} Third para from bottom: "and apply a section" is now "and apply formatting" {240} line 4: "[N$scrollbar]" is now "[$scrollbar]" {250} The first code block, line 3: changed my $key = shift to: my $key = pop {256} First para, second line: "nullifies %block" is now "nullifies @block_cells" (256) first paragraph: "addtag" is now typeset in Courier. {260} code sample 2, line 2: changed $w_top = MainWindow->new('Tetris - Perl/Tk'); to $w_top = MainWindow->new(-title => 'Tetris - Perl/Tk'); [274] line 9: changed Employee *Create(); to static Employee* Create(); (289) Resource #1 now reads: 1. Berkeley yacc for Perl, available from CPAN under src/misc/perl-byacc.tar.Z [296] line 4 of the last code example now reads: 'LIBS' => ['-L/usr/local/lib -lgd'], # Custom libraries to link with <310> Last line under "Using the scripting language's power": last sentence now reads: The embedded interpreter approach is taken by the Apache Web server [2]. {316} first code line: "main()" now reads: int main(int argc, char **argv, char **env) {332} line -5 of code: the call to create_envt_vars() now reads: create_envt_vars(env); {343} table 20-5, Description for perl_get_cv: the second sentence now reads: You should always set create to FALSE, because a TRUE value automatically creates a blank CV if the subroutine is not present, which is useless to an application writer. {343} table 20-5, Description for perl_call_sv: changed "(Yes, you'll need to cast the CV to an SV.)" to "(Yes, you'll need to cast the CV* to an SV*.)" {349} last line: inner set of parens was deleted, to make: MAGIC *m = mg_find(sv,'~'); {359} First para after code, line 3: changed "would not be an issue for ANSI C or C++ compilers" to "would not be an issue for C++ compilers" {359} Last piece of code, changed for (; *ret; ret++, i++) { XPUSHs (sv_2mortal(newSVpv(*ret, 0))); } free (ret); to char **p = ret; for (; *p; p++, i++) { XPUSHs (sv_2mortal(newSVpv(*p, 0))); } free(p) {371} #4: Deleted the sentence "Works only on Unix". (383) Table A-11 caption: Removed "(in addition to Table 8-1)" {386} #2, Array References, line 2: changed "# reference to anon. scalar" to "# reference to anonymous array" [389] #17, line 3 of code: changed create(String n, int age): _name(n), _age ...... to Employee(String n, int age): _name(n), _age ...... [390] #18, line 2 of code: "Employee->new" is now "Employee->create" {391} last line, comment: "if it supports method "foo"" is now "if it supports method "bar"" (index) Additions Brian Kernighan - p. xiv MethodMaker - p. 132 query processing - p. 182 (index) Changes "malloc command" to "malloc function" "nonnblocking" to "nonblocking"