package Robo; use Class::Inspector; sub new { my $self = { Arm => new Robo::Arm(), Feet => new Robo::Feet(), }; bless $self => $class; for my $aparent (qw/Arm Feet/){ my $obj = $self->{$aparent}; for my $amethod (@{Class::Inspector->methods( $aparent, 'full', 'public' )}){ if( $self->can($amethod) ){ warn "method '$amethod' already exists!!!!"; next } # this is totally pseudo-code and inject_method_into_self() # needs to be implemented but the spirit is obvious: inject_method_into_self($amethod, "new-name", sub { $self->{$amethod}->$amethod() } ); } } return $self }