1#!/usr/local/bin/perl 2use strict; 3use Config; 4use File::Basename qw(&basename &dirname); 5use Cwd; 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 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. 16my ($origdir, $file); 17$origdir = cwd; 18chdir(dirname($0)); 19($file = basename($0)) =~ s/\.PL$//; 20$file =~ s/\.pl$// 21 if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos'); # "case-forgiving" 22$file .= '.com' if $^O eq 'VMS'; 23 24open OUT,">$file" or die "Can't create $file: $!"; 25 26print "Extracting $file (with variable substitutions)\n"; 27 28# In this section, perl variables will be expanded during extraction. 29# You can use $Config{...} to use Configure variables. 30 31print OUT <<"!GROK!THIS!"; 32$Config{'startperl'} 33 eval 'exec perl -S \$0 "\$@"' 34 if 0; 35!GROK!THIS! 36 37# In the following, perl variables are not expanded during extraction. 38 39print OUT <<'!NO!SUBS!'; 40############################################################################# 41# podchecker -- command to invoke the podchecker function in Pod::Checker 42# 43# Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved. 44# This is free software; you can redistribute it and/or modify it under the 45# same terms as Perl itself. 46############################################################################# 47 48use strict; 49#use diagnostics; 50 51=head1 NAME 52 53podchecker - check the syntax of POD format documentation files 54 55=head1 SYNOPSIS 56 57B<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...] 58 59=head1 OPTIONS AND ARGUMENTS 60 61=over 8 62 63=item B<-help> 64 65Print a brief help message and exit. 66 67=item B<-man> 68 69Print the manual page and exit. 70 71=item B<-quiet> 72 73Do not print a success message. 74 75=item B<-warnings> B<-nowarnings> 76 77Turn on/off printing of warnings. Repeating B<-warnings> increases the 78warning level, i.e. more warnings are printed. Currently increasing to 79level two causes flagging of unescaped "E<lt>,E<gt>" characters. 80 81=item I<file> 82 83The pathname of a POD file to syntax-check (defaults to standard input). 84 85=back 86 87=head1 DESCRIPTION 88 89B<podchecker> will read the given input files looking for POD 90syntax errors in the POD documentation and will print any errors 91it find to STDERR. At the end, it will print a status message 92indicating the number of errors found. 93 94Directories are ignored, an appropriate warning message is printed. 95 96B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> 97Please see L<Pod::Checker/podchecker()> for more details. 98 99=head1 RETURN VALUE 100 101B<podchecker> returns a 0 (zero) exit status if all specified 102POD files are ok. 103 104=head1 ERRORS 105 106B<podchecker> returns the exit status 1 if at least one of 107the given POD files has syntax errors. 108 109The status 2 indicates that at least one of the specified 110files does not contain I<any> POD commands. 111 112Status 1 overrides status 2. If you want unambiguous 113results, call B<podchecker> with one single argument only. 114 115=head1 SEE ALSO 116 117L<Pod::Simple> and L<Pod::Checker> 118 119=head1 AUTHORS 120 121Please report bugs using L<http://rt.cpan.org>. 122 123Brad Appleton E<lt>bradapp@enteract.comE<gt>, 124Marek Rouchal E<lt>marekr@cpan.orgE<gt> 125 126Based on code for B<Pod::Text::pod2text(1)> written by 127Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> 128 129=cut 130 131 132use Pod::Checker; 133use Pod::Usage; 134use Getopt::Long; 135 136## Define options 137my %options; 138 139## Parse options 140GetOptions(\%options, qw(help man quiet warnings+ nowarnings)) || pod2usage(2); 141pod2usage(1) if ($options{help}); 142pod2usage(-verbose => 2) if ($options{man}); 143 144if($options{nowarnings}) { 145 $options{warnings} = 0; 146} 147elsif(!defined $options{warnings}) { 148 $options{warnings} = 1; # default is warnings on 149} 150 151## Dont default to STDIN if connected to a terminal 152pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 153 154## Invoke podchecker() 155my $status = 0; 156@ARGV = qw(-) unless(@ARGV); 157for my $podfile (@ARGV) { 158 if($podfile eq '-') { 159 $podfile = '<&STDIN'; 160 } 161 elsif(-d $podfile) { 162 warn "podchecker: Warning: Ignoring directory '$podfile'\n"; 163 next; 164 } 165 my $errors = 166 podchecker($podfile, undef, '-warnings' => $options{warnings}); 167 if($errors > 0) { 168 # errors occurred 169 $status = 1; 170 printf STDERR ("%s has %d pod syntax %s.\n", 171 $podfile, $errors, 172 ($errors == 1) ? 'error' : 'errors'); 173 } 174 elsif($errors < 0) { 175 # no pod found 176 $status = 2 unless($status); 177 print STDERR "$podfile does not contain any pod commands.\n"; 178 } 179 else { 180 print "$podfile pod syntax OK.\n" unless $options{quiet}; 181 } 182} 183exit $status; 184 185!NO!SUBS! 186 187close OUT or die "Can't close $file: $!"; 188chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 189exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 190chdir $origdir; 191