package TextClass; use Moose; has 'text' => ( is => 'rw', isa => 'Str', ); with 'PrettyPrint'; no Moose; __PACKAGE__->meta->make_immutable; 1; #### package PrettyPrint; use Moose::Role; requires 'text'; sub prettyprint { my $self = shift; print "So handsome:\n\t", $self->text, "\nYeah, sure!\n"; $self; } 1; #### use Modern::Perl qw/2014/; use lib 'D:/Perl/scripts'; # or wherever you have saved the modules use TextClass; my $person = TextClass->new( text => q/I'm CountZero/ ); $person->prettyprint; #### So handsome: I'm CountZero Yeah, sure!