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.