{
    "mode": "perldoc",
    "parameter": "Moose::Manual",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Moose%3A%3AManual/json",
    "generated": "2026-06-09T13:06:05Z",
    "sections": {
        "NAME": {
            "content": "Moose::Manual - What is Moose, and how do I use it?\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 2.2200\n\nWHAT IS MOOSE?\nMoose is a *complete* object system for Perl 5. Consider any modern object-oriented language\n(which Perl 5 definitely isn't). It provides keywords for attribute declaration, object\nconstruction, inheritance, and maybe more. These keywords are part of the language, and you\ndon't care how they are implemented.\n\nMoose aims to do the same thing for Perl 5 OO. We can't actually create new keywords, but we do\noffer \"sugar\" that looks a lot like them. More importantly, with Moose, you *define your class\ndeclaratively*, without needing to know about blessed hashrefs, accessor methods, and so on.\n\nWith Moose, you can concentrate on the *logical* structure of your classes, focusing on \"what\"\nrather than \"how\". A class definition with Moose reads like a list of very concise English\nsentences.\n\nMoose is built on top of \"Class::MOP\", a meta-object protocol (aka MOP). Using the MOP, Moose\nprovides complete introspection for all Moose-using classes. This means you can ask classes\nabout their attributes, parents, children, methods, etc., all using a well-defined API. The MOP\nabstracts away the symbol table, looking at @ISA vars, and all the other crufty Perl tricks we\nknow and love(?).\n\nMoose is based in large part on the Perl 6 object system, as well as drawing on the best ideas\nfrom CLOS, Smalltalk, and many other languages.\n\nWHY MOOSE?\nMoose makes Perl 5 OO both simpler and more powerful. It encapsulates Perl 5 power tools in\nhigh-level declarative APIs which are easy to use. Best of all, you don't need to be a wizard to\nuse it.\n\nBut if you want to dig about in the guts, Moose lets you do that too, by using and extending its\npowerful introspection API.\n",
            "subsections": []
        },
        "AN EXAMPLE": {
            "content": "package Person;\n\nuse Moose;\n\nhas 'firstname' => (\nis  => 'rw',\nisa => 'Str',\n);\n\nhas 'lastname' => (\nis  => 'rw',\nisa => 'Str',\n);\n\nno Moose;\nPACKAGE->meta->makeimmutable;\n\nThis is a *complete and usable* class definition!\n\npackage User;\n\nuse DateTime;\nuse Moose;\n\nextends 'Person';\n\nhas 'password' => (\nis  => 'rw',\nisa => 'Str',\n);\n\nhas 'lastlogin' => (\nis      => 'rw',\nisa     => 'DateTime',\nhandles => { 'dateoflastlogin' => 'date' },\n);\n\nsub login {\nmy $self = shift;\nmy $pw   = shift;\n\nreturn 0 if $pw ne $self->password;\n\n$self->lastlogin( DateTime->now() );\n\nreturn 1;\n}\n\nno Moose;\nPACKAGE->meta->makeimmutable;\n\nWhen ready to instantiate your class in an application, use it in the \"traditional\" Perl manner:\n\nuse User;\n\nmy $user = User->new(\nfirstname => 'Example',\nlastname  => 'User',\npassword   => 'letmein',\n);\n\n$user->login('letmein');\n\nsay $user->dateoflastlogin;\n\nWe'll leave the line-by-line explanation of this code to other documentation, but you can see\nhow Moose reduces common OO idioms to simple declarative constructs.\n",
            "subsections": []
        },
        "TABLE OF CONTENTS": {
            "content": "This manual consists of a number of documents.\n\nMoose::Manual::Concepts\nIntroduces Moose concepts, and contrasts them against \"old school\" Perl 5 OO.\n\nMoose::Manual::Unsweetened\nShows two example classes, each written first with Moose and then with \"plain old Perl 5\".\n\nMoose::Manual::Classes\nHow do you make use of Moose in your classes? Now that I'm a Moose, how do I subclass\nsomething?\n\nMoose::Manual::Attributes\nAttributes are a core part of the Moose OO system. An attribute is a piece of data that an\nobject has. Moose has a lot of attribute-related features!\n\nMoose::Manual::Delegation\nDelegation is a powerful way to make use of attributes which are themselves objects.\n\nMoose::Manual::Construction\nLearn how objects are built in Moose, and in particular about the \"BUILD\" and \"BUILDARGS\"\nmethods. Also covers object destruction with \"DEMOLISH\".\n\nMoose::Manual::MethodModifiers\nA method modifier lets you say \"before calling method X, do this first\", or \"wrap method X\nin this code\". Method modifiers are particularly handy in roles and with attribute\naccessors.\n\nMoose::Manual::Roles\nA role is something a class does (like \"Debuggable\" or \"Printable\"). Roles provide a way of\nadding behavior to classes that is orthogonal to inheritance.\n\nMoose::Manual::Types\nMoose's type system lets you strictly define what values an attribute can contain.\n\nMoose::Manual::MOP\nMoose's meta API system lets you ask classes about their parents, children, methods,\nattributes, etc.\n\nMoose::Manual::MooseX\nThis document describes a few of the most useful Moose extensions on CPAN.\n\nMoose::Manual::BestPractices\nMoose has a lot of features, and there's definitely more than one way to do it. However, we\nthink that picking a subset of these features and using them consistently makes everyone's\nlife easier.\n\nMoose::Manual::FAQ\nFrequently asked questions about Moose.\n\nMoose::Manual::Resources\nLinks to various tutorials, videos, blogs, presentations, interviews, etc...\n\nMoose::Manual::Contributing\nInterested in hacking on Moose? Read this.\n\nMoose::Manual::Delta\nThis document details backwards-incompatibilities and other major changes to Moose.\n",
            "subsections": []
        },
        "JUSTIFICATION": {
            "content": "If you're still asking yourself \"Why do I need this?\", then this section is for you.\n\nAnother object system!?!?\nYes, we know there are many, many ways to build objects in Perl 5, many of them based on\ninside-out objects and other such things. Moose is different because it is not a new object\nsystem for Perl 5, but instead an extension of the existing object system.\n\nMoose is built on top of Class::MOP, which is a metaclass system for Perl 5. This means that\nMoose not only makes building normal Perl 5 objects better, but it also provides the power\nof metaclass programming.\n\nIs this for real? Or is this just an experiment?\nMoose is *based* on the prototypes and experiments Stevan did for the Perl 6 meta-model.\nHowever, Moose is NOT an experiment or prototype; it is for real.\n\nIs this ready for use in production?\nYes.\n\nMoose has been used successfully in production environments by many people and companies.\nThere are Moose applications which have been in production with little or no issue now for\nyears. We consider it highly stable and we are committed to keeping it stable.\n\nOf course, in the end, you need to make this call yourself. If you have any questions or\nconcerns, please feel free to email Stevan or the moose@perl.org list, or just stop by\nirc.perl.org#moose and ask away.\n\nIs Moose just Perl 6 in Perl 5?\nNo. While Moose is very much inspired by Perl 6, it is not itself Perl 6. Instead, it is an\nOO system for Perl 5. Stevan built Moose because he was tired of writing the same old boring\nPerl 5 OO code, and drooling over Perl 6 OO. So instead of switching to Ruby, he wrote Moose\n:)\n\nWait, *post* modern, I thought it was just *modern*?\nStevan read Larry Wall's talk from the 1999 Linux World entitled \"Perl, the first postmodern\ncomputer language\" in which he talks about how he picked the features for Perl because he\nthought they were cool and he threw out the ones that he thought sucked. This got him\nthinking about how we have done the same thing in Moose. For Moose, we have \"borrowed\"\nfeatures from Perl 6, CLOS (LISP), Smalltalk, Java, BETA, OCaml, Ruby and more, and the bits\nwe didn't like (cause they sucked) we tossed aside. So for this reason (and a few others)\nStevan has re-dubbed Moose a *postmodern* object system.\n\nNuff Said.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   Stevan Little <stevan@cpan.org>\n\n*   Dave Rolsky <autarch@urth.org>\n\n*   Jesse Luehrs <doy@cpan.org>\n\n*   Shawn M Moore <sartak@cpan.org>\n\n*   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>\n\n*   Karen Etheridge <ether@cpan.org>\n\n*   Florian Ragwitz <rafl@debian.org>\n\n*   Hans Dieter Pearcey <hdp@cpan.org>\n\n*   Chris Prather <chris@prather.org>\n\n*   Matt S Trout <mstrout@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2006 by Infinity Interactive, Inc.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "Moose::Manual - What is Moose, and how do I use it?",
    "flags": [],
    "examples": [],
    "see_also": []
}