File: Count.pm

package info (click to toggle)
libcatmandu-perl 1.2012-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,564 kB
  • sloc: perl: 16,753; makefile: 24; sh: 5
file content (51 lines) | stat: -rw-r--r-- 718 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package Catmandu::Exporter::Count;

use Catmandu::Sane;

our $VERSION = '1.2012';

use Moo;
use namespace::clean;

with 'Catmandu::Exporter';

has _num => (is => 'rw', default => sub {0});

sub add {
    my $self = $_[0];
    $self->_num($self->_num + 1);
}

sub commit {
    my $self = $_[0];
    $self->fh->print($self->_num . "\n");
}

1;

__END__

=pod

=head1 NAME

Catmandu::Exporter::Count - a exporter that counts things

=head1 SYNOPSIS

    # From the commandline
    $ catmandu convert JSON to Count < /tmp/data.json


=head1 DESCRIPTION

This exporter exports nothing and just counts the number of items found
in the input data.

=head1 SEE ALSO

L<Catmandu::Cmd::count>

L<Catmandu::Exporter::Null>

=cut