package Polyze::HCount; use Moose; use Polyze::RCount; with 'Polyze::Handler'; has rcount => ( is => 'ro', isa => 'Polyze::RCount', required => 0, lazy => 1, builder => '_build_rcount', handles => [qw( increment_count )], ); sub _build_rcount { my ($self) = @_; # A reporter object requires a line. But since we don't care about # the line in this case, give it a dummy. my $rc = Polyze::RCount->new( polyze => $self->polyze, line => Polyze::Line->new( text => 'Dummy', filename => 'Dummy', linenumber => 0, ), ); $self->polyze->add_reporter($rc); return $rc; } sub scan_line { my ($self, $line) = @_; $self->increment_count; return $Polyze::CONTINUE_LINE; } no Moose; __PACKAGE__->meta->make_immutable;