## this starts like damian's example: # Rational helper class... package Astro::Data::Scientific; use base Solar::Data; use base Lunar::Data; # # "Differently rational" helper class... package Astro::Data::Mythological; use base Astrological::Data; # Pre-empt normal methods use base Astro::Data::Scientific; # # Delegating class package Astro::Data; sub new { my $class = shift; my $sun_rises_in_west = @_ ? shift : $default_sun_rises_in_west; my $delegate = ("Astro::Data::" . ($sun_rises_in_west ? "Mythological" : "Scientific"))->new; bless { delegate => $delegate, }, $class; } # define like this or use Class::Accessor sub sunrise_delegate { $_[0]{delegate}; } # define like this or use Class::Delegation sub get_sunrise_time { my $self = shift; $self->sunrise_delegate->get_sunrise_time(@_); }