Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Get me excited about perl

by tobyink (Abbot)
on Sep 19, 2012 at 19:15 UTC ( #994503=note: print w/replies, xml ) Need Help??

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'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994503]
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2017-04-28 21:15 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (528 votes). Check out past polls.