in reply to Checking on live site if subroutine exists
It's documented that way, see exists
exists ⊂ # OK
and symbolic code-refs are not limited by strict
DB<281> use strict; use warnings; $a=""; print exists &{$a} DB<282> sub foo {}; $a="foo" DB<283> use strict; use warnings; print exists &{$a} 1 DB<284>
Tho I prefer PACKAGE->can('subname') b/c it's more readable and returns a coderef.
See UNIVERSAL for documentation.
OK there is indeed a fine difference here, because ->can would also report inherited methods and exists wouldn't.
Point is, if you are using OOP, then can is what you normally want.
Otherwise without OOP, you can't get bitten by inheritance.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|