The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
package Catmandu::Counter;

use Catmandu::Sane;
use Moo::Role;

has count => (is => 'ro', init_arg => undef, default => sub { 0 });

sub inc_count {
    ++$_[0]->{count};
}

sub dec_count {
    my $self = $_[0]; $self->{count} ? --$self->{count} : 0;
}

sub reset_count {
    $_[0]->{count} = 0;
}

1;