PDA

View Full Version : testing a module's loading ability


chrisbragg
11-14-2003, 05:14 PM
Hello

Let's say I want to load the module [use CGI;]. How can I make a test that will let me know whether that module can load successfully or not?

Something like:

if (use CGI){print 'hurray';}
else{print 'sad face';}

... but something that actually works.


thank you!

Jeff Mott
11-14-2003, 08:05 PM
eval { require CGI; };
print $@ ? 'sad face' : 'hurray';

chrisbragg
11-14-2003, 09:54 PM
Excellent.

I had tried the eval statement like this [eval(require CGI)] but didn't realise it could be used with the brakets [eval{1;}]

Thank you!