#!/usr/bin/perl # Program name: mip1.pl Run it, thusly: perl mip1.pl Moose is Perl (i.e., MIP or mip) presentation. # From https://cdn.oreillystatic.com/en/assets/1/event/115/Moose%20is%20Perl_%20A%20Guide%20to%20the%20New%20Revolution%20Presentation%202.pdf. use strict; use warnings; use feature 'say'; local $| = 1; # Forces a flush. use v5.12; # Starting with v5.12, we can use a new syntax that allows us to use a block with our package statements. package Employee { use Moose; has name => (is => 'ro'); has title => (is => 'rw'); sub name_and_title { my ($self) = @_; my $name = $self->name; my $title = $self->title; return "$name, $title"; } no Moose; } # use Employee; my $peon = Employee->new({ name => 'William Toady', title => 'Associate Assistant', }); print $peon->name_and_title, "\n"; # Get name_and_title. $peon->title("Assistant to the Associate"); print $peon->name_and_title, "\n"; # Get name_and_title. $peon->name("William Riker"); print $peon->name_and_title, "\n"; # Get name_and_title. __END__