|more useful options
How to identify available subclasses?by olliecook (Initiate)
|on Sep 08, 2008 at 13:45 UTC
olliecook has asked for the wisdom of the Perl Monks concerning the following question:
Given a tree of modules that are available to the interpreter:
Is there a programmatic way to identify the names of modules that are children below a certain point in the tree, say "A::B" or just "A"?
My specific question is I have a number of log parsers which inherit from a superclass. I would like the superclass to 'offer' a log line to each parser (dynamically determined at run-time) as a test to see whether that parser can handle files in that format. For this to work, I need to be able to identify what subclasses exist under the superclass.
It would be possible to traverse each element of @INC, but that strikes me as rather ugly.
Is there a better way?