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

Yitzchak Scott-Thoennes sthoenna at efn.org
Wed Nov 21 23:57:40 GMT 2007

On Mon, November 19, 2007 2:53 pm, Dirk Koopman wrote:
> I *would* like to know "defined *Local::bar" always returns true.

Because mentioning any {$,@,%,&,*,iohandle}Local::bar thingy (or defining
a format) causes the glob to be created.

$ perl -le'print 0+defined *Local::bar'

Symbolic reference works:

$ perl -wle'print 0+defined *{"Local::bar"}'

(in a defined-context, anyway):

$ perl -wle'print !!*{"Local::bar"}, 0+defined *{"Local::bar"}'

Note that the non-symbolic reference creates
the glob at compile time, not run time:

$ perl -le'print 0+defined *{"Local::bar"}, 0+defined *Local::bar'

More information about the london.pm mailing list