Quoting Bryn Dyment <[EMAIL PROTECTED]>: > I've been reading the mod_perl performance docs, and have a few yes/no-style > (I hope) questions. > > Questions (using DBI as an example*): > > 1. If my preloaded (via startup.pl) "my.pm" module uses DBI, should I > explicitly "use DBI ()" in startup.pl as well?
You don't have to, as DBI will be loaded already by your own module. > 2. Related to that, is it then kosher for my (non-preloaded Mason) "my.html" > component to call a DBI method directly (e.g., "$dbH->disconnect")? Or... Yes. All the code during the request cycle will be handled by the same perl interpreter. So since DBI will be preloaded at startup, no other module will have to load it to use it. However, you should still put a 'use DBI ();' at the top of each file that uses DBI. This will ensure that it is loaded if in the future you remove the startup stuff. The call to 'use DBI ();' will check %INC to see if DBI is already loaded, and it won't do it again. > 3. Should all calls to DBI from my ".html" components always be made > indirectly, via (for example) the preloaded "my.pm" module (e.g. calling > "$myH->myDisconnect")? They can be, but don't have to be (see answer 2). > 4. I read about "use DBI" vs. "use DBI ()". Does this hold true for my own > modules, too? (I'm asking, because I'm looking at someone's startup.pl > file, and they're only using "()" for the CPAN modules, not their own.) The difference between the two has to do with copying functions and/or variables into your namespace. The command 'use DBI;' will load DBI if necesary, and then call the 'import' method of DBI. It is up to DBI to decide if it wants to 'export' any of its functions into your namespace. To see what a module exports, you can search for EXPORT in the source code of the module or read the module docs. If in your own modules you do not inherit from 'Exporter', and you don't have your own 'import' subroutine, then the () will become optional, as there is nothing there to import into your namespace. Most people when they write their own modules have no need of exporting functions, and hence you doing need to worry about the (). It is always safe to include though. I hope that helps. Cheers, Cees -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html