in reply to Re: subclass discovery at runtime
in thread subclass discovery at runtime

That will look at @Foo::ISA, but not @Foo::Bar::ISA. The latter can only be found via the Bar:: key in the Foo:: symbol table, so you'd have to change your code to recurse the tables.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^2: subclass discovery at runtime
by Gilimanjaro (Hermit) on Jan 27, 2003 at 17:26 UTC
    Very true; in fact I've had very little success while experimenting with my own suggestion!

    It seems that UNIVERSAL::isa is not doing at all what I'm expecting it to do...

    print UNIVERSAL::isa('SubClass','SuperClass') ? 'true' : 'false'; package SuperClass; package SubClass; use vars qw(@ISA); @ISA=qw(SuperClass);
    Seems to print false! Does this mean 'isa' only works on objects? Not on class-names?

    I feel like a noob... I'd consider doing a '--' on my own original post, if I could...

    Update: Aristotle got me on track again... Temporary insanity resolved

      Are you doing it in that order? Because the @ISA = qw(SuperClass); only happens at runtime, and by the time the print executes you haven't yet arrived at it. Wrap it in BEGIN {} and it will work.

      Makeshifts last the longest.

        Yep... You're right... I just figured that out... Discovered an issue with recursing thru the namespace too; seems there's a 'main::main::' entry, which causes infinite recursion, so you'd need to keep track of what namespaces you've checked...