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;

# 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] [-h] [-n number] [-p] [-r] ".
		"[-s section] pod_file_or_module\n";
	print STDERR "\t-d flag\t\tTurn debug (0/1) (default is 1).\n";
	print STDERR "\t-e\t\tEnumerate lines (0/1) (default is 0). ".
		"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";
	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'});

__END__

=pod

=encoding utf8

=head1 NAME

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

=head1 SYNOPSIS

 pod_example -h

=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.04

=cut