{
    "mode": "perldoc",
    "parameter": "Moo::Role",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/json",
    "generated": "2026-06-12T05:36:47Z",
    "synopsis": "package My::Role;\nuse Moo::Role;\nuse strictures 2;\nsub foo { ... }\nsub bar { ... }\nhas baz => (\nis => 'ro',\n);\n1;\nAnd elsewhere:\npackage Some::Class;\nuse Moo;\nuse strictures 2;\n# bar gets imported, but not foo\nwith 'My::Role';\nsub foo { ... }\n1;",
    "sections": {
        "NAME": {
            "content": "Moo::Role - Minimal Object Orientation support for Roles\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package My::Role;\n\nuse Moo::Role;\nuse strictures 2;\n\nsub foo { ... }\n\nsub bar { ... }\n\nhas baz => (\nis => 'ro',\n);\n\n1;\n\nAnd elsewhere:\n\npackage Some::Class;\n\nuse Moo;\nuse strictures 2;\n\n# bar gets imported, but not foo\nwith 'My::Role';\n\nsub foo { ... }\n\n1;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Moo::Role\" builds upon Role::Tiny, so look there for most of the documentation on how this\nworks (in particular, using \"Moo::Role\" also enables strict and warnings). The main addition\nhere is extra bits to make the roles more \"Moosey;\" which is to say, it adds \"has\".\n",
            "subsections": []
        },
        "IMPORTED SUBROUTINES": {
            "content": "See \"IMPORTED SUBROUTINES\" in Role::Tiny for all the other subroutines that are imported by this\nmodule.\n\nhas\nhas attr => (\nis => 'ro',\n);\n\nDeclares an attribute for the class to be composed into. See \"has\" in Moo for all options.\n",
            "subsections": []
        },
        "CLEANING UP IMPORTS": {
            "content": "Moo::Role cleans up its own imported methods and any imports declared before the \"use Moo::Role\"\nstatement automatically. Anything imported after \"use Moo::Role\" will be composed into consuming\npackages. A package that consumes this role:\n\npackage My::Role::ID;\n\nuse Digest::MD5 qw(md5hex);\nuse Moo::Role;\nuse Digest::SHA qw(sha1hex);\n\nrequires 'name';\n\nsub asmd5  { my ($self) = @; return md5hex($self->name);  }\nsub assha1 { my ($self) = @; return sha1hex($self->name); }\n\n1;\n\n..will now have a \"$self->sha1hex()\" method available to it that probably does not do what you\nexpect. On the other hand, a call to \"$self->md5hex()\" will die with the helpful error message:\n\"Can't locate object method \"md5hex\"\".\n\nSee \"CLEANING UP IMPORTS\" in Moo for more details.\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "See Moo for support and contact information.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "See Moo for authors.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "See Moo for the copyright and license.\n",
            "subsections": []
        }
    },
    "summary": "Moo::Role - Minimal Object Orientation support for Roles",
    "flags": [],
    "examples": [],
    "see_also": []
}