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

# Pragmas.
use strict;
use warnings;

# Modules.
use App::Pod::Example;
use Getopt::Std;

# Version.
our $VERSION = 0.06;

# Arguments.
my $opts_hr = {
	'd' => 1,
	'h' => 0,
	'e' => 0,
	'n' => undef,
	'p' => 0,
	'r' => 0,
	's' => 'EXAMPLE',
};
if (! getopts('d:ehn:prs:', $opts_hr) || @ARGV < 1 || $opts_hr->{'h'} 
	|| (! $opts_hr->{'p'} && ! $opts_hr->{'r'})) {

	print STDERR "Usage: $0 [-d flag] [-e] [-h] [-n number] [-p] [-r]\n".
		"\t[-s section] [--version] pod_file_or_module\n\n";
	print STDERR "\t-d flag\t\tTurn debug (0/1) (default is 1).\n";
	print STDERR "\t-e\t\tEnumerate lines. Only for print mode.\n";
	print STDERR "\t-h\t\tHelp.\n";
	print STDERR "\t-n number\tNumber of example (default is ".
		"nothing).\n";
	print STDERR "\t-p\t\tPrint example.\n";
	print STDERR "\t-r\t\tRun example.\n";
	print STDERR "\t-s section\tUse section (default EXAMPLE).\n";
	print STDERR "\t--version\tPrint version.\n";
	exit 1;
}
my $pod_file = $ARGV[0];

# Run.
App::Pod::Example->new(
	'debug' => $opts_hr->{'d'},
	'enumerate' => $opts_hr->{'e'},
	'print' => $opts_hr->{'p'},
	'run' => $opts_hr->{'r'},
)->run($pod_file, $opts_hr->{'s'}, $opts_hr->{'n'});

# Print version.
sub VERSION_MESSAGE {
	print $VERSION."\n";
	exit 0;
}

__END__

=pod

=encoding utf8

=head1 NAME

pod_example - Script to print or run of example from documentation.

=head1 SYNOPSIS

 pod_example [-d flag] [-e] [-h] [-n number] [-p] [-r] [-s section] [--version] pod_file_or_module

=head1 ARGUMENTS

=over 8

=item * C<-d flag>

Turn debug (0/1) (default is 1).

=item * C<-e>

Enumerate lines. Only for print mode.

=item * C<-h>

Print help.

=item * C<-n number>

Number of example (default is nothing).

=item * C<-p>

Print example.

=item * C<-r>

Run example.

=item * C<-s section>

Use section (default EXAMPLE).

=item * C<--version>

Print version of script.

=back

=head1 EXAMPLE

 pod_example -p -r Class::Utils

=head1 REPOSITORY

L<https://github.com/tupinek/App-Pod-Example>

=head1 AUTHOR

Michal Špaček L<mailto:skim@cpan.org>

L<http://skim.cz>

=head1 LICENSE AND COPYRIGHT

BSD license.

=head1 VERSION

0.06

=cut