{
    "mode": "info",
    "parameter": "Moose::Meta::Attribute::Native::Trait::Counter",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/Moose%3A%3AMeta%3A%3AAttribute%3A%3ANative%3A%3ATrait%3A%3ACounter/json",
    "generated": "2026-07-05T06:16:14Z",
    "synopsis": "package MyHomePage;\nuse Moose;\nhas 'counter' => (\ntraits  => ['Counter'],\nis      => 'ro',\nisa     => 'Num',\ndefault => 0,\nhandles => {\ninccounter   => 'inc',\ndeccounter   => 'dec',\nresetcounter => 'reset',\n},\n);\nmy $page = MyHomePage->new();\n$page->inccounter;    # same as $page->counter( $page->counter + 1 );\n$page->deccounter;    # same as $page->counter( $page->counter - 1 );\nmy $countbytwos = 2;\n$page->inccounter($countbytwos);",
    "sections": {
        "Moose::Meta::AttributeUsertMoose::Meta::Attribute::Native::Trait::Counter(3pm)": {
            "content": "",
            "subsections": []
        },
        "NAME": {
            "content": "Moose::Meta::Attribute::Native::Trait::Counter - Helper trait for Int\nattributes which represent counters\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 2.2200\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package MyHomePage;\nuse Moose;\n\nhas 'counter' => (\ntraits  => ['Counter'],\nis      => 'ro',\nisa     => 'Num',\ndefault => 0,\nhandles => {\ninccounter   => 'inc',\ndeccounter   => 'dec',\nresetcounter => 'reset',\n},\n);\n\nmy $page = MyHomePage->new();\n$page->inccounter;    # same as $page->counter( $page->counter + 1 );\n$page->deccounter;    # same as $page->counter( $page->counter - 1 );\n\nmy $countbytwos = 2;\n$page->inccounter($countbytwos);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This trait provides native delegation methods for counters. A counter\ncan be any sort of number (integer or not). The delegation methods\nallow you to increment, decrement, or reset the value.\n",
            "subsections": []
        },
        "DEFAULT TYPE": {
            "content": "If you don't provide an \"isa\" value for your attribute, it will default\nto \"Num\".\n",
            "subsections": []
        },
        "PROVIDED METHODS": {
            "content": "o   set($value)\n\nSets the counter to the specified value and returns the new value.\n\nThis method requires a single argument.\n\no   inc\n\no   inc($arg)\n\nIncreases the attribute value by the amount of the argument, or by\n1 if no argument is given. This method returns the new value.\n\nThis method accepts a single argument.\n\no   dec\n\no   dec($arg)\n\nDecreases the attribute value by the amount of the argument, or by\n1 if no argument is given. This method returns the new value.\n\nThis method accepts a single argument.\n\no   reset\n\nResets the value stored in this slot to its default value, and\nreturns the new value.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "See \"BUGS\" in Moose for details on reporting bugs.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "o   Stevan Little <stevan@cpan.org>\n\no   Dave Rolsky <autarch@urth.org>\n\no   Jesse Luehrs <doy@cpan.org>\n\no   Shawn M Moore <sartak@cpan.org>\n\no    ' (Yuval Kogman) <nothingmuch@woobling.org>\n\no   Karen Etheridge <ether@cpan.org>\n\no   Florian Ragwitz <rafl@debian.org>\n\no   Hans Dieter Pearcey <hdp@cpan.org>\n\no   Chris Prather <chris@prather.org>\n\no   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\nthe same terms as the Perl 5 programming language system itself.\n\nperl v5.34.0               Moose::Meta::Attribute::Native::Trait::Counter(3pm)",
            "subsections": []
        }
    },
    "summary": "Moose::Meta::Attribute::Native::Trait::Counter - Helper trait for Int attributes which represent counters",
    "flags": [],
    "examples": [],
    "see_also": []
}