Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello all!

Let's say i have a module called My::Object. I create children My::Object::Child1 and My::Object::Child2.
1) How can i write a method in My::Object that will return the list of all children?
2) Where would this be useful?

Thank you all in advance!

Replies are listed 'Best First'.
Re: Object's method to list its children
by GrandFather (Saint) on Sep 23, 2010 at 02:16 UTC

    If you can't think of a place where such a thing would be useful (question 2) then it's not surprising that you haven't given us an example that might make your meaning clear. Perhaps you need to come up with a real application that requires the technique you are puzzling over, then describe it to us and show us the code you have tried.

    True laziness is hard work
Re: Object's method to list its children
by Anonymous Monk on Sep 23, 2010 at 01:50 UTC
    What do you mean by "children"? Do you mean subclasses of or instances of the package "My::Object"? Or something else?
Re: Object's method to list its children
by Anonymous Monk on Sep 23, 2010 at 02:50 UTC
    Nvm, this was a quiz question, and i think i misunderstood what was being asked. Looks like they meant children in a literal sense, as in human beings, not in the OO sense. Thank you for making me reread the question for 101th time - apparently the first 100 didnt help :o)