Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found