191f110e0Safresh1#!/usr/local/bin/perl 2256a93a4Safresh1use strict; 391f110e0Safresh1use Config; 491f110e0Safresh1use File::Basename qw(&basename &dirname); 591f110e0Safresh1use Cwd; 691f110e0Safresh1 791f110e0Safresh1# List explicitly here the variables you want Configure to 891f110e0Safresh1# generate. Metaconfig only looks for shell variables, so you 991f110e0Safresh1# have to mention them as if they were shell variables, not 1091f110e0Safresh1# %Config entries. Thus you write 1191f110e0Safresh1# $startperl 1291f110e0Safresh1# to ensure Configure will look for $Config{startperl}. 1391f110e0Safresh1 1491f110e0Safresh1# This forces PL files to create target in same directory as PL file. 1591f110e0Safresh1# This is so that make depend always knows where to find PL derivatives. 16256a93a4Safresh1my ($origdir, $file); 1791f110e0Safresh1$origdir = cwd; 1891f110e0Safresh1chdir(dirname($0)); 1991f110e0Safresh1($file = basename($0)) =~ s/\.PL$//; 2091f110e0Safresh1$file =~ s/\.pl$// 2191f110e0Safresh1 if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos'); # "case-forgiving" 2291f110e0Safresh1$file .= '.com' if $^O eq 'VMS'; 2391f110e0Safresh1 2491f110e0Safresh1open OUT,">$file" or die "Can't create $file: $!"; 2591f110e0Safresh1 2691f110e0Safresh1print "Extracting $file (with variable substitutions)\n"; 2791f110e0Safresh1 2891f110e0Safresh1# In this section, perl variables will be expanded during extraction. 2991f110e0Safresh1# You can use $Config{...} to use Configure variables. 3091f110e0Safresh1 3191f110e0Safresh1print OUT <<"!GROK!THIS!"; 3291f110e0Safresh1$Config{'startperl'} 3391f110e0Safresh1 eval 'exec perl -S \$0 "\$@"' 3491f110e0Safresh1 if 0; 3591f110e0Safresh1!GROK!THIS! 3691f110e0Safresh1 3791f110e0Safresh1# In the following, perl variables are not expanded during extraction. 3891f110e0Safresh1 3991f110e0Safresh1print OUT <<'!NO!SUBS!'; 4091f110e0Safresh1############################################################################# 4191f110e0Safresh1# podchecker -- command to invoke the podchecker function in Pod::Checker 4291f110e0Safresh1# 4391f110e0Safresh1# Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved. 445759b3d2Safresh1# This is free software; you can redistribute it and/or modify it under the 455759b3d2Safresh1# same terms as Perl itself. 4691f110e0Safresh1############################################################################# 4791f110e0Safresh1 4891f110e0Safresh1use strict; 4991f110e0Safresh1#use diagnostics; 5091f110e0Safresh1 5191f110e0Safresh1=head1 NAME 5291f110e0Safresh1 5391f110e0Safresh1podchecker - check the syntax of POD format documentation files 5491f110e0Safresh1 5591f110e0Safresh1=head1 SYNOPSIS 5691f110e0Safresh1 5791f110e0Safresh1B<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...] 5891f110e0Safresh1 5991f110e0Safresh1=head1 OPTIONS AND ARGUMENTS 6091f110e0Safresh1 6191f110e0Safresh1=over 8 6291f110e0Safresh1 6391f110e0Safresh1=item B<-help> 6491f110e0Safresh1 6591f110e0Safresh1Print a brief help message and exit. 6691f110e0Safresh1 6791f110e0Safresh1=item B<-man> 6891f110e0Safresh1 6991f110e0Safresh1Print the manual page and exit. 7091f110e0Safresh1 71*5486feefSafresh1=item B<-quiet> 72*5486feefSafresh1 73*5486feefSafresh1Do not print a success message. 74*5486feefSafresh1 7591f110e0Safresh1=item B<-warnings> B<-nowarnings> 7691f110e0Safresh1 7791f110e0Safresh1Turn on/off printing of warnings. Repeating B<-warnings> increases the 7891f110e0Safresh1warning level, i.e. more warnings are printed. Currently increasing to 7991f110e0Safresh1level two causes flagging of unescaped "E<lt>,E<gt>" characters. 8091f110e0Safresh1 8191f110e0Safresh1=item I<file> 8291f110e0Safresh1 8391f110e0Safresh1The pathname of a POD file to syntax-check (defaults to standard input). 8491f110e0Safresh1 8591f110e0Safresh1=back 8691f110e0Safresh1 8791f110e0Safresh1=head1 DESCRIPTION 8891f110e0Safresh1 8991f110e0Safresh1B<podchecker> will read the given input files looking for POD 9091f110e0Safresh1syntax errors in the POD documentation and will print any errors 9191f110e0Safresh1it find to STDERR. At the end, it will print a status message 9291f110e0Safresh1indicating the number of errors found. 9391f110e0Safresh1 9491f110e0Safresh1Directories are ignored, an appropriate warning message is printed. 9591f110e0Safresh1 9691f110e0Safresh1B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> 9791f110e0Safresh1Please see L<Pod::Checker/podchecker()> for more details. 9891f110e0Safresh1 9991f110e0Safresh1=head1 RETURN VALUE 10091f110e0Safresh1 10191f110e0Safresh1B<podchecker> returns a 0 (zero) exit status if all specified 10291f110e0Safresh1POD files are ok. 10391f110e0Safresh1 10491f110e0Safresh1=head1 ERRORS 10591f110e0Safresh1 10691f110e0Safresh1B<podchecker> returns the exit status 1 if at least one of 10791f110e0Safresh1the given POD files has syntax errors. 10891f110e0Safresh1 10991f110e0Safresh1The status 2 indicates that at least one of the specified 11091f110e0Safresh1files does not contain I<any> POD commands. 11191f110e0Safresh1 11291f110e0Safresh1Status 1 overrides status 2. If you want unambiguous 11391f110e0Safresh1results, call B<podchecker> with one single argument only. 11491f110e0Safresh1 11591f110e0Safresh1=head1 SEE ALSO 11691f110e0Safresh1 1175759b3d2Safresh1L<Pod::Simple> and L<Pod::Checker> 11891f110e0Safresh1 11991f110e0Safresh1=head1 AUTHORS 12091f110e0Safresh1 12191f110e0Safresh1Please report bugs using L<http://rt.cpan.org>. 12291f110e0Safresh1 12391f110e0Safresh1Brad Appleton E<lt>bradapp@enteract.comE<gt>, 12491f110e0Safresh1Marek Rouchal E<lt>marekr@cpan.orgE<gt> 12591f110e0Safresh1 12691f110e0Safresh1Based on code for B<Pod::Text::pod2text(1)> written by 12791f110e0Safresh1Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> 12891f110e0Safresh1 12991f110e0Safresh1=cut 13091f110e0Safresh1 13191f110e0Safresh1 13291f110e0Safresh1use Pod::Checker; 13391f110e0Safresh1use Pod::Usage; 13491f110e0Safresh1use Getopt::Long; 13591f110e0Safresh1 13691f110e0Safresh1## Define options 13791f110e0Safresh1my %options; 13891f110e0Safresh1 13991f110e0Safresh1## Parse options 140*5486feefSafresh1GetOptions(\%options, qw(help man quiet warnings+ nowarnings)) || pod2usage(2); 14191f110e0Safresh1pod2usage(1) if ($options{help}); 14291f110e0Safresh1pod2usage(-verbose => 2) if ($options{man}); 14391f110e0Safresh1 14491f110e0Safresh1if($options{nowarnings}) { 14591f110e0Safresh1 $options{warnings} = 0; 14691f110e0Safresh1} 14791f110e0Safresh1elsif(!defined $options{warnings}) { 14891f110e0Safresh1 $options{warnings} = 1; # default is warnings on 14991f110e0Safresh1} 15091f110e0Safresh1 15191f110e0Safresh1## Dont default to STDIN if connected to a terminal 15291f110e0Safresh1pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 15391f110e0Safresh1 15491f110e0Safresh1## Invoke podchecker() 15591f110e0Safresh1my $status = 0; 15691f110e0Safresh1@ARGV = qw(-) unless(@ARGV); 15791f110e0Safresh1for my $podfile (@ARGV) { 15891f110e0Safresh1 if($podfile eq '-') { 15991f110e0Safresh1 $podfile = '<&STDIN'; 16091f110e0Safresh1 } 16191f110e0Safresh1 elsif(-d $podfile) { 16291f110e0Safresh1 warn "podchecker: Warning: Ignoring directory '$podfile'\n"; 16391f110e0Safresh1 next; 16491f110e0Safresh1 } 16591f110e0Safresh1 my $errors = 16691f110e0Safresh1 podchecker($podfile, undef, '-warnings' => $options{warnings}); 16791f110e0Safresh1 if($errors > 0) { 16891f110e0Safresh1 # errors occurred 16991f110e0Safresh1 $status = 1; 17091f110e0Safresh1 printf STDERR ("%s has %d pod syntax %s.\n", 17191f110e0Safresh1 $podfile, $errors, 17291f110e0Safresh1 ($errors == 1) ? 'error' : 'errors'); 17391f110e0Safresh1 } 17491f110e0Safresh1 elsif($errors < 0) { 17591f110e0Safresh1 # no pod found 17691f110e0Safresh1 $status = 2 unless($status); 17791f110e0Safresh1 print STDERR "$podfile does not contain any pod commands.\n"; 17891f110e0Safresh1 } 17991f110e0Safresh1 else { 180*5486feefSafresh1 print "$podfile pod syntax OK.\n" unless $options{quiet}; 18191f110e0Safresh1 } 18291f110e0Safresh1} 18391f110e0Safresh1exit $status; 18491f110e0Safresh1 18591f110e0Safresh1!NO!SUBS! 18691f110e0Safresh1 18791f110e0Safresh1close OUT or die "Can't close $file: $!"; 18891f110e0Safresh1chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 18991f110e0Safresh1exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 19091f110e0Safresh1chdir $origdir; 191