[OT] best way to determine existence of a function in a package

Jonathan Stowe jns at gellyfish.com
Mon Nov 19 10:33:49 GMT 2007

On Mon, 2007-11-19 at 09:53 +0000, Dirk Koopman wrote:
> The problem:
> A user may include a local version of a package which may include one or 
>   more local versions of a static function (there are no references, 
> blessed or otherwise to ->can() on).
> I want to detect whether or not that function is explicitly defined.
> if (defined *Local::function) {
>     ...
>     ...
> }
> except that expression always returns true, which is rather a nuisance.

You cant to examine the CODE slot of the typeglob:

if (defined *Local::function{CODE} )
   # ....

This may not work on ye ancieunte perls, but I can't remember when it
was introduced.


More information about the london.pm mailing list