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.\"
>
Here's how I'm going about it:
sub do_optional_thing {
init_special_support();
Module::Special::wow();
}
sub init_special_support {
# check whether module is already loaded
return if defined $INC{'Module/Special'};
eval {
require Module::Special;
Module::Special->import();
};
croak "Special feature not supported: Module::Special not available" if $@;
}