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

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

Replies are listed 'Best First'.
Re^4: subclass discovery at runtime
by Aristotle (Chancellor) on Jan 27, 2003 at 17:40 UTC
    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...
        Sort of. There's a main:: in every package; just skip that entry and you'll be fine.

        Makeshifts last the longest.