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

Paul LeoNerd Evans leonerd at leonerd.org.uk
Mon Nov 19 11:16:08 GMT 2007

On Mon, 19 Nov 2007 09:53:41 +0000
Dirk Koopman <djk at tobit.co.uk> wrote:

> 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).

You don't need a reference. I've always found that UNIVERSAL::can() works
just as well:

  if( my $subref = UNIVERSAL::can( "Package", "function" ) ) {
     $subref->( args, here );

Paul "LeoNerd" Evans

leonerd at leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://london.pm.org/pipermail/london.pm/attachments/20071119/cca994d3/signature.pgp

More information about the london.pm mailing list