in reply to defined &{ $pkg . '::foo' } vs. $pkg->can( 'foo' )
You almost always want to use exists &subname rather than defined &subname; there's no advantage in excluding declared-but-not-defined subs.$ perl -w sub foo; sub AUTOLOAD { print "called $AUTOLOAD" } print "is foo defined? ",0+defined &foo, " does foo exist? ", 0+exists + &foo, "\n"; foo(); __END__ is foo defined? 0 does foo exist? 1 called main::foo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: defined &{ $pkg . '::foo' } vs. $pkg->can( 'foo' )
by tlm (Prior) on Jul 15, 2005 at 12:56 UTC | |
by ysth (Canon) on Jul 15, 2005 at 20:26 UTC | |
by tlm (Prior) on Jul 15, 2005 at 20:48 UTC |