On Tue, Nov 25, 2003 at 10:43:27AM -0800, Bryn Dyment wrote:
[snip]
> 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?

The second `use DBI' will be ignored, since DBI is already in %INC.
Doesn't hurt to include it, though.  It will avoid annoying errors if
you ever remove `my.pm' for whatever reason.

> 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...

Assuming `$dbH' is somehow available to your Mason component.  It's a
blessed reference, so Perl knows what method to call.

> 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")?

Does `my.pm' provide any added functionality over DBI?

> 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.)

Yes and no.  It depends on whether or not you export any symbols using
Exporter (or a custom import() method).  `use DBI' both requires DBI and
calls its import() method to import any symbols into your namespace.
`use DBI ()' skips the call to import().  Many people (myself included)
always use the parens to avoid potential namespace pollution.

-chris

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to