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
In reply to Re^2: Conditional use of modules
by Anonymous Monk
in thread Conditional use of modules
by tkguifan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |