in reply to Re: Conditional use of modules
in thread Conditional use of modules
use or require it in an eval and then immediately test the value of $@
See for example the section "Background" in Try::Tiny for a discussion of the problems with $@. It's safer to do something like this:
print eval 'use Data::Dumper; 1' ? 'success' : 'failure', "\n"; print eval 'use Unknown; 1' ? 'success' : 'failure', "\n"; __END__ success failure
|
|---|