{
    "mode": "perldoc",
    "parameter": "Moose::Meta::Attribute::Native::Trait::Counter",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Moose%3A%3AMeta%3A%3AAttribute%3A%3ANative%3A%3ATrait%3A%3ACounter/json",
    "generated": "2026-06-13T01:07:12Z",
    "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": {
        "NAME": {
            "content": "Moose::Meta::Attribute::Native::Trait::Counter - Helper trait for Int attributes which represent\ncounters\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 can be any sort of number\n(integer or not). The delegation methods allow 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 to \"Num\".\n",
            "subsections": []
        },
        "PROVIDED METHODS": {
            "content": "*   set($value)\n\nSets the counter to the specified value and returns the new value.\n\nThis method requires a single argument.\n\n*   inc\n\n*   inc($arg)\n\nIncreases the attribute value by the amount of the argument, or by 1 if no argument is\ngiven. This method returns the new value.\n\nThis method accepts a single argument.\n\n*   dec\n\n*   dec($arg)\n\nDecreases the attribute value by the amount of the argument, or by 1 if no argument is\ngiven. This method returns the new value.\n\nThis method accepts a single argument.\n\n*   reset\n\nResets the value stored in this slot to its default value, and returns the new value.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "See \"BUGS\" in Moose for details on reporting bugs.\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::Meta::Attribute::Native::Trait::Counter - Helper trait for Int attributes which represent counters",
    "flags": [],
    "examples": [],
    "see_also": []
}