I wanted to be able to do this in Perl (the code below is Python lol)
try:
import Module
except:
print "You need module Module to run this program."
Does anyone have any idea how to?
I wanted to be able to do this in Perl (the code below is Python lol)
try:
import Module
except:
print "You need module Module to run this program."
Does anyone have any idea how to?
Something like this,
use Net::SMTP
if you have the module installed, or a cheesysendmail
callout as a last resort.If you don't have Module installed, you will get the error "Can't locate Module.pm in @INC (@INC contains: ...)." which is understandable enough.
Is there some particular reason you want/need a more specific message?
There are many modules for doing that; see the list of CPAN modules that (can) load other modules. However, it is a bit risky to rely on an external module (what if it is not present?). Well, at least, if you rely on Moose, Class::Load can be used safely as it is Moose's prerequisite:
You can use Module::Load::Conditional
Here's how I'm going about it:
TIMTOWTDI:
or
or
You can find Module::Load on CPAN.