[ Ignore this post. I missed the "In the real module" bit initially. I'll post something else in a minute. ]
Close. Change
tomy $ob1 = foo->new('alpha'); my $ob2 = foo->new('beta');
And set @ISA for alpha and beta.my $ob1 = alpha->new(); my $ob2 = beta->new();
use strict; use warnings; my $ob1 = alpha->new() my $ob2 = beta->new() $ob1->write; $ob2->write; BEGIN { package foo; sub new{ my $class = shift; return bless {}, $class; } sub write{ my $self = shift; print $self->read; } } BEGIN { package alpha; our @ISA = 'foo'; sub read{ return "Alpha\n"; } } BEGIN { package beta; our @ISA = 'foo'; sub read{ return "Beta\n"; } }
In reply to Re: Dynamically setting up inheritence at runtime
by ikegami
in thread Dynamically setting up inheritence at runtime
by hangon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |