+ 'version' => sub {
+ say "barcat version $VERSION";
+ exit;
+ },
+ 'usage|h' => sub {
+ local $/ = undef; # slurp
+ my $pod = readline *DATA;
+ $pod =~ s/^=over\K/ 25/; # indent options list
+ $pod =~ s{
+ ^=item \h \N*\n\n \N*\n \K # first line
+ (?: (?: ^=over .*? ^=back\n )? (?!=) \N*\n )*
+ }{\n}g; # abbreviate options
+ $pod =~ s/[.,](?=\n)//g; # trailing punctuation
+ $pod =~ s/^=item\ \K(?=--)/____/g; # align long options
+ # abbreviate <variable> indicators
+ $pod =~ s/\Q>.../s>/g;
+ $pod =~ s/<(?:number|count|seconds)>/N/g;
+ $pod =~ s/<character(s?)>/\Uchar$1/g;
+ $pod =~ s/\Q | /|/g;
+ $pod =~ s/(?<!\w)<([a-z]+)>/\U$1/g; # uppercase
+
+ require Pod::Usage;
+ my $parser = Pod::Usage->new(USAGE_OPTIONS => {
+ -indent => 2, -width => 78,
+ });
+ $parser->select('SYNOPSIS', 'OPTIONS');
+ $parser->output_string(\my $contents);
+ $parser->parse_string_document($pod);
+
+ $contents =~ s/\n(?=\n\h)//msg; # strip space between items
+ $contents =~ s/^\ \ \K____/ /g; # nbsp substitute
+ print $contents;
+ exit;
+ },
+ 'help|?' => sub {
+ require Pod::Usage;
+ Pod::Usage::pod2usage(
+ -exitval => 0, -perldocopt => '-oman', -verbose => 2,
+ );
+ },