{
    "mode": "perldoc",
    "parameter": "Moose::Cookbook",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Moose%3A%3ACookbook/json",
    "generated": "2026-06-10T05:14:57Z",
    "sections": {
        "NAME": {
            "content": "Moose::Cookbook - How to cook a Moose\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 2.2200\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The Moose cookbook is a series of recipes showing various Moose features. Most recipes present\nsome code demonstrating some feature, and then explain the details of the code.\n\nYou should probably read the Moose::Manual first. The manual explains Moose concepts without\nbeing too code-heavy.\n",
            "subsections": []
        },
        "RECIPES": {
            "content": "",
            "subsections": [
                {
                    "name": "Basic Moose",
                    "content": "These recipes will give you a good overview of Moose's capabilities, starting with simple\nattribute declaration, and moving on to more powerful features like laziness, types, type\ncoercion, method modifiers, and more.\n\nMoose::Cookbook::Basics::PointAttributesAndSubclassing\nA simple Moose-based class. Demonstrates basic Moose attributes and subclassing.\n\nMoose::Cookbook::Basics::BankAccountMethodModifiersAndSubclassing\nA slightly more complex Moose class. Demonstrates using a method modifier in a subclass.\n\nMoose::Cookbook::Basics::BinaryTreeAttributeFeatures\nDemonstrates several attribute features, including types, weak references, predicates (\"does\nthis object have a foo?\"), defaults, laziness, and triggers.\n\nMoose::Cookbook::Basics::CompanySubtypes\nIntroduces the creation and use of custom types, a \"BUILD\" method, and the use of \"override\"\nin a subclass. This recipe also shows how to model a set of classes that could be used to\nmodel companies, people, employees, etc.\n\nMoose::Cookbook::Basics::HTTPSubtypesAndCoercion\nThis recipe covers more subtype creation, including the use of type coercions.\n\nMoose::Cookbook::Basics::Immutable\nMaking a class immutable greatly increases the speed of accessors and object construction.\n\nMoose::Cookbook::Basics::BinaryTreeBuilderAndLazyBuild - Builder methods and lazybuild\nThe builder feature provides an inheritable and role-composable way to provide a default\nattribute value.\n\nMoose::Cookbook::Basics::GenomeOverloadingSubtypesAndCoercion\nDemonstrates using operator overloading, coercion, and subtypes to model how eye color is\ndetermined during reproduction.\n\nMoose::Cookbook::Basics::PersonBUILDARGSAndBUILD\nThis recipe demonstrates the use of \"BUILDARGS\" and \"BUILD\" to hook into object\nconstruction.\n\nMoose::Cookbook::Basics::DateTimeExtendingNonMooseParent\nIn this recipe, we make a Moose-based subclass of DateTime, a module which does not use\nMoose itself.\n\nMoose::Cookbook::Basics::DocumentAugmentAndInner\nDemonstrates the use of \"augment\" method modifiers, a way of turning the usual method\noverriding style \"inside-out\".\n"
                },
                {
                    "name": "Moose Roles",
                    "content": "These recipes will show you how to use Moose roles.\n\nMoose::Cookbook::Roles::ComparableCodeReuse\nDemonstrates roles, which are also sometimes known as traits or mix-ins. Roles provide a\nmethod of code re-use which is orthogonal to subclassing.\n\nMoose::Cookbook::Roles::RestartableAdvancedComposition\nSometimes you just want to include part of a role in your class. Sometimes you want the\nwhole role but one of its methods conflicts with one in your class. With method exclusion\nand aliasing, you can work around these problems.\n\nMoose::Cookbook::Roles::ApplicationToInstance\nIn this recipe, we apply a role to an existing object instance.\n"
                },
                {
                    "name": "Meta Moose",
                    "content": "These recipes show you how to write your own meta classes, which lets you extend the object\nsystem provided by Moose.\n\nMoose::Cookbook::Meta::WhyMeta\nIf you're wondering what all this \"meta\" stuff is, and why you should care about it, read\nthis \"recipe\".\n\nMoose::Cookbook::Meta::LabeledAttributeTrait\nExtending Moose's attribute metaclass is a great way to add functionality. However,\nattributes can only have one metaclass. Applying roles to the attribute metaclass lets you\nprovide composable attribute functionality.\n\nMoose::Cookbook::Meta::TableMetaclassTrait\nThis recipe takes the class metaclass we saw in the previous recipe and reimplements it as a\nmetaclass trait.\n\nMoose::Cookbook::Meta::PrivateOrPublicMethodMetaclass\nThis recipe shows a custom method metaclass that implements making a method private.\n\nMoose::Cookbook::Meta::GlobRefInstanceMetaclass\nThis recipe shows an example of how you create your own meta-instance class. The\nmeta-instance determines the internal structure of object instances and provide access to\nattribute slots.\n\nIn this particular instance, we use a blessed glob reference as the instance instead of a\nblessed hash reference.\n\nHooking into immutabilization (TODO)\nMoose has a feature known as \"immutabilization\". By calling\n\"PACKAGE->meta()->makeimmutable()\" after defining your class (attributes, roles, etc),\nyou tell Moose to optimize things like object creation, attribute access, and so on.\n\nIf you are creating your own metaclasses, you may need to hook into the immutabilization\nsystem. This cuts across a number of spots, including the metaclass class, meta method\nclasses, and possibly the meta-instance class as well.\n\nThis recipe shows you how to write extensions which immutabilize properly.\n"
                },
                {
                    "name": "Extending Moose",
                    "content": "These recipes cover some more ways to extend Moose, and will be useful if you plan to write your\nown \"MooseX\" module.\n\nMoose::Cookbook::Extending::ExtensionOverview\nThere are quite a few ways to extend Moose. This recipe provides an overview of each method,\nand provides recommendations for when each is appropriate.\n\nMoose::Cookbook::Extending::DebuggingBaseClassRole\nMany base object class extensions can be implemented as roles. This example shows how to\nprovide a base object class debugging role that is applied to any class that uses a notional\n\"MooseX::Debugging\" module.\n\nMoose::Cookbook::Extending::MooseishMooseSugar\nThis recipe shows how to provide a replacement for \"Moose.pm\". You may want to do this as\npart of the API for a \"MooseX\" module, especially if you want to default to a new metaclass\nclass or base object class.\n"
                }
            ]
        },
        "SNACKS": {
            "content": "Moose::Cookbook::Snack::Keywords\nMoose::Cookbook::Snack::Types\n",
            "subsections": []
        },
        "Legacy Recipes": {
            "content": "These cover topics that are no longer considered best practice. We've kept them in case in you\nencounter these usages in the wild.\n\nMoose::Cookbook::Legacy::LabeledAttributeMetaclass\nMoose::Cookbook::Legacy::TableClassMetaclass\nMoose::Cookbook::Legacy::DebuggingBaseClassReplacement\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "<http://www.gsph.com/index.php?Lang=En&ID=291>\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::Cookbook - How to cook a Moose",
    "flags": [],
    "examples": [],
    "see_also": []
}