Møøse

Roles are reusable

package Person;
use Moose;

with 'Comparable', 'Printable';

has 'first_name' => (is => 'rw', isa => 'Str');
has 'last_name'  => (is => 'rw', isa => 'Str');  

sub to_string {
    my $self = shift;
    $self->last_name . ', ' . $self->first_name;
}  

sub compare {
    my ($self, $other) = @_;
    $self->to_string cmp $other->to_string;
}
Copyright © 2006 Stevan Little