in reply to Calling chains, extends, and subclassing
Its a bit icky, but you could put 'make_question' into your base Quiz class, munge the type name and do something like this:
I would have expected this to require no strict 'refs', but it doesn't seem to.package NHB::QuizMaster::Quiz; sub make_question { my $s = shift; my $type = ref $s; # X::Y::Z::Quiz $type =~ s/::Quiz$/::Question/; my $question = new $type; ...etc }
It also feels a bit icky, but maybe that's just me.
|
|---|