in reply to Question about UNIVERSAL::can
A package does not have to be loaded to be useful e.g. we can add a sub to a package and then call it, even though we didn't load it:
thus it makes sense to be able to test it with can (whether we loaded it or not).% perl -E '*Some::Module::foo = sub { say "hello" }; Some::Module::foo +()' hello
It seems that as an empty package can do nothing, searching for 'can' leads to nothing.
However this is not the case for a non-empty package:% perl -E 'say Some::Module->can("can")'
or even% perl -E '*Some::Module::foo = sub { }; say Some::Module->can("can")' + CODE(0x259d370)
% perl -E '*Some::Module::foo = sub { say "far out man!" }; say Some:: +Module->can("can")->("Some::Module", "foo")->()' far out man! 1
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Question about UNIVERSAL::can
by schetchik (Beadle) on May 29, 2013 at 21:18 UTC |
In Section
Seekers of Perl Wisdom