#!/home/centos/perldoc-browser/perls/5.41.2/bin/perl eval 'exec /home/centos/perldoc-browser/perls/5.41.2/bin/perl -S $0 ${1+"$@"}' if 0; # ^ Run only under a shell # Convert POD data to formatted *roff input. # # The driver script for Pod::Man. # # SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl use 5.012; use warnings; use Getopt::Long qw(GetOptions); use Pod::Man (); use Pod::Usage qw(pod2usage); # Format a single POD file. # # $parser - Pod::Man object to use # $input - Input file, - or undef for standard input # $output - Output file, - or undef for standard output # $verbose - Whether to print each file to standard output when converted # # Returns: 0 on no errors, 1 if there was an error sub format_file { my ($parser, $input, $output, $verbose) = @_; my $to_stdout = !defined($output) || $output eq q{-}; if ($verbose && !$to_stdout) { print " $output\n" or warn "$0: cannot write to stdout: $!\n"; } $parser->parse_from_file($input, $output); if ($parser->{CONTENTLESS}) { if (defined($input) && $input ne q{-}) { warn "$0: unable to format $input\n"; } else { warn "$0: unable to format standard input\n"; } if (!$to_stdout && !-s $output) { unlink($output); } return 1; } return 0; } # Clean up $0 for error reporting. $0 =~ s{ .*/ }{}xms; # Insert -- into @ARGV before any single dash argument to hide it from # Getopt::Long; we want to interpret it as meaning stdin. my $stdin; local @ARGV = map { $_ eq q{-} && !$stdin++ ? (q{--}, $_) : $_ } @ARGV; # Parse our options, trying to retain backward compatibility with pod2man but # allowing short forms as well. --lax is currently ignored. my %options; Getopt::Long::config('bundling_override'); GetOptions( \%options, 'center|c=s', 'date|d=s', 'encoding|e=s', 'errors=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s', 'fixedbolditalic=s', 'guesswork=s', 'help|h', 'lax|l', 'language=s', 'lquote=s', 'name|n=s', 'nourls', 'official|o', 'quotes|q=s', 'release|r=s', 'rquote=s', 'section|s=s', 'stderr', 'verbose|v', 'utf8|u', ) or exit 1; if ($options{help}) { pod2usage(0); } # Official sets --center, but don't override things explicitly set. if ($options{official} && !defined($options{center})) { $options{center} = 'Perl Programmers Reference Guide'; } # Delete flags that are only used in pod2man, not in Pod::Man. lax is accepted # only for backward compatibility and does nothing. my $verbose = $options{verbose}; delete @options{qw(verbose lax official)}; # If neither stderr nor errors is set, default to errors = die rather than the # Pod::Man default of pod. if (!defined($options{stderr}) && !defined($options{errors})) { $options{errors} = 'die'; } # If given no arguments, read from stdin and write to stdout. if (!@ARGV) { push(@ARGV, q{-}); } # Initialize and run the formatter, pulling a pair of input and output off at # a time. For each file, we check whether the document was completely empty # and, if so, will remove the created file and exit with a non-zero exit # status. my $parser = Pod::Man->new(%options); my $status = 0; while (@ARGV) { my ($input, $output) = splice(@ARGV, 0, 2); my $result = format_file($parser, $input, $output, $verbose); $status ||= $result; } exit($status); __END__ =for stopwords en em --stderr stderr --utf8 UTF-8 overdo markup MT-LEVEL Allbery Solaris URL troff troff-specific formatters uppercased Christiansen --nourls UTC prepend lquote rquote unrepresentable mandoc manref EBCDIC =head1 NAME pod2man - Convert POD data to formatted *roff input =head1 SYNOPSIS pod2man [B<--center>=I] [B<--date>=I] [B<--encoding>=I] [B<--errors>=I