Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Conditionally faking a module

by bobf (Monsignor)
on Jan 13, 2010 at 19:14 UTC ( #817262=note: print w/replies, xml ) Need Help??


in reply to Re^2: Conditionally faking a module
in thread Conditionally faking a module

Apparently it may not always work, as I learned when I researched this further (see RE: Checking to see if a particular Module is installed). merlyn's response was to use the following:

eval 'require GD'; if ($@) { # problems with GD, fall back to non-GD } else { # we have GD, go for it! }
although there appears to be some caveats to that approach.

If you are open to using other modules to do the check, you could look into ExtUtils::Installed and Module::Load::Conditional.

See also a recent thread on this topic: Check if module is installed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://817262]
help
Chatterbox?
[stevieb]: I am thankful that I fell into Perl years ago in the manner I did. I don't believe there is another language that people care about so much, that they're willing to give everything. Langs come and go, but in Perl, it seems, things remain consistent.
[stevieb]: The people back then (~2000) are the same people now, but with much more experience. I'm appreciative that I fell into the Perl rabbit hole.
[stevieb]: Coding circles around Python devs, showing how unit tests should be done, enabling easy access to everything, learning basic C to wrap for direct hardware access... I am thankful.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-02-25 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (364 votes). Check out past polls.