##
package Package;
sub y { shift->x }
####
{ package SomeRole;
# Implementor must provide y
sub y { shift->x }
}
{ package Class;
our @ISA = 'SomeRole';
sub x { ... }
}
####
sub some_method {
my ($self, $arg) = @_
...
$arg->other_method();
...
}
####
sub some_method {
my ($self) = @_
...
$self->attribute->other_method();
...
}