Roles
Learn about roles in Perl.
We'll cover the following...
A role is a named collection of behavior and state. Whereas a class organizes behaviors and state into a template for objects, a role organizes a named collection of behaviors and state. We can instantiate a class but not a role. A role is something a class does.
Defining a role
Given an Animal that has an age and a Cheese that can age, one difference may be that Animal does the LivingBeing role, while Cheese does the Storable role:
Press +  to interact
package LivingBeing {use Moose::Role;requires qw( name age diet );}
The requires keyword provided by Moose::Role allows us to list methods that this role requires of its composing classes. ...
 Ask