Hi,
Given a tree of modules that are available to the interpreter:
A
A::B
A::B::C
A::B::D
A::B::E
A::C::D
A::C::E
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?
Thanks,
Ollie
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.