http://www.perlmonks.org?node_id=792937


in reply to Re: Use a module only if it is in use
in thread Use a module only if it is in use

The & was what I forgot in my tests!!!

M::hello("again") if exists &M::hello;

also works. Thank you!

Replies are listed 'Best First'.
Re^3: Use a module only if it is in use
by ikegami (Patriarch) on Sep 02, 2009 at 15:13 UTC

    exists returns true if the sub is declared, whether it's been defined or not.

    defined returns true if the sub is defined.

    sub foo; # exists but not defined sub bar {} # exists and defined