B::clearsym
[p5sagit/p5-mst-13.2.git] / pod / podchecker.PL
CommitLineData
360aca43 1#!/usr/local/bin/perl
2
3use Config;
4use File::Basename qw(&basename &dirname);
933fea7f 5use Cwd;
360aca43 6
7# List explicitly here the variables you want Configure to
8# generate. Metaconfig only looks for shell variables, so you
9# have to mention them as if they were shell variables, not
10# %Config entries. Thus you write
11# $startperl
12# to ensure Configure will look for $Config{startperl}.
13
3b5ca523 14# This forces PL files to create target in same directory as PL file.
15# This is so that make depend always knows where to find PL derivatives.
933fea7f 16$origdir = cwd;
3b5ca523 17chdir(dirname($0));
18($file = basename($0)) =~ s/\.PL$//;
19$file =~ s/\.pl$//
933fea7f 20 if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos'); # "case-forgiving"
360aca43 21
22open OUT,">$file" or die "Can't create $file: $!";
23
24print "Extracting $file (with variable substitutions)\n";
25
26# In this section, perl variables will be expanded during extraction.
27# You can use $Config{...} to use Configure variables.
28
29print OUT <<"!GROK!THIS!";
30$Config{'startperl'}
31 eval 'exec perl -S \$0 "\$@"'
32 if 0;
33!GROK!THIS!
34
35# In the following, perl variables are not expanded during extraction.
36
37print OUT <<'!NO!SUBS!';
38#############################################################################
39# podchecker -- command to invoke the podchecker function in Pod::Checker
40#
41# Derived from Tom Christiansen's pod2text script.
42# (with extensive modifications)
43#
44# Copyright (c) 1998 Bradford Appleton. All rights reserved.
45# This file is part of "PodParser". PodParser is free software;
46# you can redistribute it and/or modify it under the same terms
47# as Perl itself.
48#############################################################################
49
50use strict;
51use diagnostics;
52
53=head1 NAME
54
55podchecker - check the syntax of POD format documentation files
56
57=head1 SYNOPSIS
58
59B<podchecker> [B<-help>] [B<-man>] [I<file>S< >...]
60
61=head1 OPTIONS AND ARGUMENTS
62
63=over 8
64
65=item B<-help>
66
67Print a brief help message and exit.
68
69=item B<-man>
70
71Print the manual page and exit.
72
73=item I<file>
74
75The pathname of a POD file to syntax-check (defaults to standard input).
76
77=back
78
79=head1 DESCRIPTION
80
81B<podchecker> will read the given input files looking for POD
82syntax errors in the POD documentation and will print any errors
83it find to STDERR. At the end, it will print a status message
84indicating the number of errors found.
85
86B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>
87Please see L<Pod::Checker/podchecker()> for more details.
88
89=head1 SEE ALSO
90
91L<Pod::Parser> and L<Pod::Checker>
92
93=head1 AUTHOR
94
95Brad Appleton E<lt>bradapp@enteract.comE<gt>
96
97Based on code for B<Pod::Text::pod2text(1)> written by
98Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
99
100=cut
101
102
103use Pod::Checker;
104use Pod::Usage;
105use Getopt::Long;
106
107## Define options
108my %options = (
109 "help" => 0,
110 "man" => 0,
111);
112
113## Parse options
114GetOptions(\%options, "help", "man") || pod2usage(2);
115pod2usage(1) if ($options{help});
116pod2usage(-verbose => 2) if ($options{man});
117
118## Dont default to STDIN if connected to a terminal
119pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
120
121## Invoke podchecker()
122if(@ARGV) {
123 for (@ARGV) { podchecker($_) };
124} else {
125 podchecker("<&STDIN");
126}
127
128!NO!SUBS!
129
130close OUT or die "Can't close $file: $!";
131chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
132exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
933fea7f 133chdir $origdir;