in reply to Use a module only if it is in use

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

Not exactly sure what you want to achieve... but maybe you just want

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

Replies are listed 'Best First'.
Re^2: Use a module only if it is in use
by vitoco (Hermit) on Sep 02, 2009 at 14:57 UTC

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

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

    also works. Thank you!

      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