Here's an example using my latest plaything, MooX::Pression. Raku-like syntax, but it's Perl 5.

use v5.14; use strict; use warnings; package Local { use MooX::Pression; class Employee { has name (type => Str, required => true); has title (type => Str, required => true); method name_and_title () { my $name = $self->name; my $title = $self->title; return "$name, $title"; } } class Employee::Former { extends Employee; factory former_employee; has +title = "Team Member"; around name_and_title () { my $old = $self->$next(@_); return "$old (Former)"; } } } my $peon = Local->new_employee( name => 'William Toady', title => 'Associate Assistant', ); say $peon->name_and_title; my $ex_peon = Local->former_employee( name => 'William Toady', title => 'Associate Assistant', ); say $ex_peon->name_and_title; my $ex_peon2 = Local->former_employee( name => 'William Toady', ); say $ex_peon2->name_and_title; __END__ William Toady, Associate Assistant William Toady, Associate Assistant (Former) William Toady, Team Member (Former)

Of course, this uses Moo instead of Moose. If you prefer Moose...

use MooX::Pression toolkit => "Moose";

In reply to Re: Raku question: "Moose is Perl", but it sure ain't Raku. by tobyink
in thread Raku question: "Moose is Perl", but it sure ain't Raku. by Cow1337killr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.