On Wed, 2006-19-04 at 14:05 -0600, siegfried wrote: > This code works, but I don't understand it. It is in a source file with the > extension of ".pm". I have a static variable agent that needs to be > initialized prior to the first function call. > > Should not I need to use the BEGIN statement so the cookie and proxy > functions get called? Apparently they are getting called anyway. The begin > statement just gave me syntax errors. > > And what is the deal with @ISA? Is that not used for inheritance? What is > the descendant class here? And what does __PACKAGE__ mean? > > Thanks, > siegfried
__PACKAGE__ is the name of the current package, see `perldoc perldata` and search for 'Special Literals' Below is a script and a module to show why you don't need BEGIN. In short, the 'main' part of a module is executed when it is used. myscript -------- #!/usr/bin/perl use strict; use warnings; BEGIN { print "BEGIN part of myscript\n"; } print "main part of myscript before `use MyModule;`\n"; use MyModule; print "main part of myscript after `use MyModule;`\n"; END { print "END part of myscript\n"; } __END__ MyModule.pm ----------- #!/ # MyModule.pm BEGIN { print "BEGIN part of MyModule.pm\n"; } print "'main' part of MyModule.pm\n"; END { print "END part of MyModule.pm\n"; } 1; __END__ -- __END__ Just my 0.00000002 million dollars worth, --- Shawn "For the things we have to learn before we can do them, we learn by doing them." Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>