# A.pm
package A;
use 5.014;
use Moo;
sub say_hello {
my $self = shift;
my ($name) = @_;
say "Hello, $name!";
}
1;
####
# C.pm
package C;
use 5.014;
use Moo;
has 'name' => (is => 'rw');
sub say_goodbye {
my $self = shift;
say 'Goodbye, ', $self->name, '!';
}
1;
##
##
# C1.pm
package C1;
use 5.014;
use strict;
use warnings;
use Moo;
extends 'C';
use A;
has '_a' => (is => 'ro',
default => sub { A->new() },
handles => [qw(say_hello)]
);
1;
##
##
use strict;
use warnings;
use C1;
my $c = C1->new(name => 'John Doe');
$c->say_hello('World');
$c->say_goodbye;
##
##
package C1;
use parent (qw(A B C D));