Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Check if module is installed

by JavaFan (Canon)
on Nov 16, 2009 at 11:46 UTC ( [id://807420]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Check if module is installed
in thread Check if module is installed

Checking $@ is not an appropriate way to check if an eval failed. An eval can fail, but in the clean up (DESTROY for instance), something can unset $@.

The only way to make sure an eval succeeded is to check its return value:

eval "use Some::Module 94.5; 1" or do { printf "Loading Some::Module failed: %s", $@ // "Unknown error"; ... };

Replies are listed 'Best First'.
Re^5: Check if module is installed
by DrHyde (Prior) on Nov 17, 2009 at 10:36 UTC
    Can you give an example that would make my code Do The Wrong Thing? Cos I can't think of any way of doing that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://807420]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found