[Boulder.pm] How do I catch "Can't locate <module>.pm" errors at runtime

Janine Goldstein janine at ucar.edu
Mon Oct 19 10:07:26 PDT 2009


Hi Boulder Perl Mongers,

I have been trolling the web looking for help with a programming problem and I found your group. Hopefully this is a good place to ask my question.


I have some code that uses a Perl module and I would like to catch the
 error "Can't locate <module>.pm in @INC" at runtime, give use user an
 error message telling them they need to run the code on a different
 machine, and exit gracefully.
 
I have tried:

no warnings FATAL
eval {use <module>}; warn $@ if $@;
BEGIN {$SIG{"__WARN__"} = sub {...};
try {use <module>;} catch {...};

all to no avail. Am I messing up the syntax or is there something more
fundamental going on?

Thanks for any and all help!!!!

Janine



More information about the Boulder-pm mailing list