The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!perl

use 5.010;
use strict;
use warnings;

use Org::Parser;

our $VERSION = '0.46'; # VERSION

my $org = Org::Parser->new;
my $doc;
{
    local $/;
    $doc = $org->parse(~~<>);
}

my $n = 0;
$doc->walk(
    sub {
        my $el = shift;
        $n++ if $el->isa('Org::Element::Headline') &&
            $el->is_todo && !$el->is_done;
    });

say $n;

# ABSTRACT: Count todos which are undone in Org document
# PODNAME: count-undone-org-todos

__END__

=pod

=encoding UTF-8

=head1 NAME

count-undone-org-todos - Count todos which are undone in Org document

=head1 VERSION

This document describes version 0.46 of count-undone-org-todos (from Perl distribution App-OrgUtils), released on 2017-07-10.

=head1 SYNOPSIS

 % count-undone-org-todos todo.org
 42

which is equivalent to:

 % list-org-todos todo.org | wc -l
 % list-org-todos --nodone todo.org | wc -l

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-OrgUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-OrgUtils>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-OrgUtils>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 SEE ALSO

L<Org::Parser>

L<count-done-org-todos>

L<count-org-todos>

L<list-org-todos>

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut