in reply to Revisiting strict and @ISA

When you attempt to call the method, @ISA has not yet been assigned. You could put that line in a BEGIN{}, or have it in a separate file.

Incidentally you messed up the my $class = ref($proto) || $proto meme. Which there are some good reasons not to use, it is better to make the method start with my $class = shift;

A random style note. As is pointed out in Code Complete, while many different indentation/brace styles are pretty much equivalent (as long as you are consistent), there is experimental evidence indicating that comprehension is best with indents in the 2-4 range. An indent of 6 or 8 may look more attractive, but is harder to work with. Therefore I'd strongly suggest reducing how much you indent.

Replies are listed 'Best First'.
Re^2: Revisiting strict and @ISA
by Zen Seeker (Initiate) on Oct 29, 2004 at 21:56 UTC
    Thanks for the BEGIN solution; that did the trick. Actual code uses something like
    my $case = new Case1(...); ... print $case->xml; Package Guts; sub new { ... } sub xml { return '...'; } Package Case1; BEGIN { @Case1::ISA = qw(Guts) } sub xml { my $self = shift; return '<case1>' . $self->SUPER::xml . '</case1>'; } Package Case2; BEGIN { @Case2::ISA = qw(Guts) } sub xml { my $self = shift; return '<case2>' . $self->SUPER::xml . '</case2>'; }