Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: test for subroutine existence

by fuzzyping (Chaplain)
on Aug 12, 2002 at 14:02 UTC ( [id://189491]=note: print w/replies, xml ) Need Help??

in reply to test for subroutine existence

Seems like eval() works fine for you, but, if you simply want to check for a sub's existence without having to perform a call on it, just use defined() (or the implied defined):

You may also use defined(&func) to check whether subroutine &func has ever been defined. The return value is unaffected by any forward declarations of &foo. Note that a subroutine which is not defined may still be callable: its package may have an AUTOLOAD method that makes it spring into existence the first time that it is called -- see perlsub.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://189491]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-07-23 18:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.