---
name: "Catmandu::Counter"
section: "3pm"
platform: "linux"
package: "libcatmandu-perl"
version: "1.2024-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::Counter"
---

# Catmandu::Counter(3pm)

A Base class for modules who need to count things

## NAME

Catmandu::Counter - A Base class for modules who need to count things

## SYNOPSIS

```
    package MyPackage;
    use Moo;
    with 'Catmandu::Counter';
    sub calculate {
        my ($self) = @_;
        $self->inc_count;
        #...do stuff
    }
    package main;
    my $x = MyPackage->new;
    $x->calculate;
    $x->calculate;
    $x->calculate;
    print "Executed calculate %d times\n" , $x->count;
```

## ATTRIBUTES

### count

The current value of the counter.

## METHODS

### inc\_count()

### inc\_count(NUMBER)

Increment the counter.

### dec\_count()

### dec\_count(NUMBER)

Decrement the counter.

### reset\_count()

Reset the counter to zero.

## SEE ALSO

Catmandu::Exporter
