in reply to Get me excited about perl

use 5.010; use MooseX::DeclareX types => [ -Moose ]; class Worker { has task_list => ( traits => ['Array'], is => read_only, isa => ArrayRef[Str], handles => { add_task => 'push', next_task => 'shift', has_no_tasks => 'is_empty', }, ); build task_list { return []; } method do_work (Int $amount = 1) { for (1 .. $amount) { return if $self->has_no_tasks; say "Doing: ", $self->next_task; } } } role Lazy { before do_work { say "Work?! Do I have to?!" } } class Lazy::Worker extends Worker with Lazy; my $bob = Lazy::Worker->new; $bob->add_task($_) for ( "dig up the road", "pull out the broken pipes", "lay down new pipes", "fill in hole", ); $bob->do_work; $bob->do_work(2); $bob->do_work(3);
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Get me excited about perl
Download Code