Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Use a module only if it is in use

by vitoco (Friar)
on Sep 02, 2009 at 14:57 UTC ( #792937=note: print w/replies, xml ) Need Help??


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 (Pope) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://792937]
help
Chatterbox?
shmem puts down the Canon garments and dresses as Chancellor
[vrk]: Congratulations. You should have Cookies
[shmem]: thanks vrk - but I'll rather have a plate of "silly con charme"
Lady_Aleena is trying to explain perl regexen to people right now and explaining how variables expand in regexen.
[Lady_Aleena]: The people I'm talking with think /$var/ looks weird with some saying it shouldn't work.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2017-04-28 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (520 votes). Check out past polls.