in reply to CGI::Application and object inheritance

When you assign to @ISA, you are removing the reference to CGI::Application. Putting a print "@ISA\n" after the use base... line and then after the @ISA=... line shows the problem:
package Foo; + use base 'CGI::Application'; print "@ISA\n"; use Bar; @ISA = ("Bar"); print "@ISA\n"; # at this point Foo only inherits from Bar __END__ CGI::Application Bar
Rather than mixing use of use base and directly assigning to @ISA, consider the use of @ISA alone:
use CGI::Application; use Bar; @Foo::ISA = qw(CGI::Application Bar);
BTW, I believe "bar" should be capitalized in your original code.

--sacked

Replies are listed 'Best First'.
Re^2: CGI::Application and object inheritance
by ikegami (Patriarch) on Jul 27, 2005 at 14:58 UTC

    The order of your statements is deceptive. use happens at compile time, so your code actually runs them in the following order:

    package Foo; use base 'CGI::Application'; use Bar; print "@ISA\n"; @ISA = ("Bar"); print "@ISA\n";

    The first print should be wrapped in a begin to have it exected at before the use Bar.

    Same results in this case, but it's something for which one should look out, especially when demonstrating a point.