in reply to How to tell methods exist in a package
Update: tirwhan has raised an important distinction. This method will only tell you if the package contains a sub with that name. If the package inherits a sub with that name, it won't return true. So the choice depends on whether your logic requires 'package has subroutine named x' or 'package can do x'.use strict; use warnings; if (exists &FOO::bar) { print "bar exists in foo\n"; } package FOO; sub bar { }
--------------------------------------------------------------
"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to tell methods exist in a package
by tirwhan (Abbot) on Nov 20, 2005 at 12:07 UTC | |
by jeanluca (Deacon) on Nov 21, 2005 at 17:36 UTC | |
by tirwhan (Abbot) on Nov 21, 2005 at 17:50 UTC | |
by jeanluca (Deacon) on Nov 21, 2005 at 19:35 UTC |