in reply to Best way to check for installed module

if (defined eval "require My::Module") {

If the name of the module is constant, you should use eval BLOCK instead of eval STRING:

if (defined eval { require My::Module }) {
Apart from that, your approach is very common, and I have yet to see a better way to do it.

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk

Replies are listed 'Best First'.
Re: Re: Best way to check for installed module
by extremely (Priest) on Apr 04, 2002 at 20:40 UTC
    The block form may be safe with require but don't fall into that trap and use the block form with "use Module"; since the perl compiler will spot the use xxx long before the wrapping code is actually executed...

    --
    $you = new YOU;
    honk() if $you->love(perl)