The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


MooX::ChainedAttributes - Make your attributes chainable.


    package Foo;
    use Moo;
    use MooX::ChainedAttributes;
    has name => (
        is      => 'rw',
        chained => 1,
    has age => (
        is => 'rw',
    sub who {
        my ($self) = @_;
        print "My name is " . $self->name() . "!\n";
    my $foo = Foo->new();
    $foo->name('Fred')->who(); # My name is Fred!


This module exists for your method chaining enjoyment. It was originally developed in order to support the porting of MooseX::Attribute::Chained using classes to Moo.

In Moose you would write:

    package Bar;
    use Moose;
    use MooseX::Attribute::Chained;
    has baz => ( is=>'rw', traits=>['Chained'] );

To port the above to Moo just change it to:

    package Bar;
    use Moo;
    use MooX::ChainedAttributes;
    has baz => ( is=>'rw', chained=>1 );


    Aran Clary Deltac <>


    Graham Knop <>


This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.