http://www.perlmonks.org?node_id=1035689


in reply to RFC: Simulating Python's @decorators in Perl with Attributes

Without introducing sub attributes into the mix (I have nothing against attributes myself, but they're uncommon enough that non-Monks may trip on them), I find that Class::Method::Modifiers does a good enough job of providing the same functionality as decorators without extra syntax. Moo exposes C::M::M directly while Moose reimplements it (unless I'm mistaken?). (Edit: tobyink points out that I am in fact mistaken, Moose got there first.)

use strict; use warnings; use 5.010; use Test::More; use Class::Method::Modifiers; sub makebold { my ($orig, @args) = @_; return '<b>'.$orig->(@args).'</b>'; } sub hello { return "ohai"; } around 'hello' => \&makebold; is(hello(), '<b>ohai</b>'); done_testing;