Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: checking for preloaded modules

by sachmet (Scribe)
on Apr 18, 2001 at 01:20 UTC ( #73347=note: print w/replies, xml ) Need Help??


in reply to checking for preloaded modules

To answer your first question, you could always check to see if the symbol table entries exist. For example:
> perl print "Data::Dumper exists\n" if %Data::Dumper::; > perl -MData::Dumper print "Data::Dumper exists\n" if %Data::Dumper::; Data::Dumper exists
So you could do:
if (%HTML::Template::) { # HTML::template stuff } else { # Regular HTML stuff }
Keep in mind, however, there is a caveat to that: if you load HTML::Template::othermodule without loading HTML::Template, that may fail. Instead, you can do:
if (exists ${%HTML::Template::}{'import'}) { ... }
which checks for the existance of the import subroutine. import is in every package by default, and that can be used to see if it exists (and hence if a module has been loaded by that name).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://73347]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2021-04-20 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?