1#!/usr/local/bin/perl 2 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. 16$origdir = cwd; 17chdir(dirname($0)); 18$file = basename($0, '.PL'); 19$file .= '.com' if $^O eq 'VMS'; 20 21open OUT,">$file" or die "Can't create $file: $!"; 22 23print "Extracting $file (with variable substitutions)\n"; 24 25# In this section, perl variables will be expanded during extraction. 26# You can use $Config{...} to use Configure variables. 27 28print OUT <<"!GROK!THIS!"; 29$Config{'startperl'} 30 eval 'exec perl -S \$0 "\$@"' 31 if 0; 32!GROK!THIS! 33 34# In the following, perl variables are not expanded during extraction. 35 36print OUT <<'!NO!SUBS!'; 37 38############################################################################# 39# pod2usage -- command to print usage messages from embedded pod docs 40# 41# Copyright (c) 1996-2000 by Bradford Appleton. All rights reserved. 42# This file is part of "PodParser". PodParser is free software; 43# you can redistribute it and/or modify it under the same terms 44# as Perl itself. 45############################################################################# 46 47use strict; 48#use diagnostics; 49 50=head1 NAME 51 52pod2usage - print usage messages from embedded pod docs in files 53 54=head1 SYNOPSIS 55 56=over 12 57 58=item B<pod2usage> 59 60[B<-help>] 61[B<-man>] 62[B<-exit>S< >I<exitval>] 63[B<-output>S< >I<outfile>] 64[B<-verbose> I<level>] 65[B<-pathlist> I<dirlist>] 66[B<-formatter> I<module>] 67I<file> 68 69=back 70 71=head1 OPTIONS AND ARGUMENTS 72 73=over 8 74 75=item B<-help> 76 77Print a brief help message and exit. 78 79=item B<-man> 80 81Print this command's manual page and exit. 82 83=item B<-exit> I<exitval> 84 85The exit status value to return. 86 87=item B<-output> I<outfile> 88 89The output file to print to. If the special names "-" or ">&1" or ">&STDOUT" 90are used then standard output is used. If ">&2" or ">&STDERR" is used then 91standard error is used. 92 93=item B<-verbose> I<level> 94 95The desired level of verbosity to use: 96 97 1 : print SYNOPSIS only 98 2 : print SYNOPSIS sections and any OPTIONS/ARGUMENTS sections 99 3 : print the entire manpage (similar to running pod2text) 100 101=item B<-pathlist> I<dirlist> 102 103Specifies one or more directories to search for the input file if it 104was not supplied with an absolute path. Each directory path in the given 105list should be separated by a ':' on Unix (';' on MSWin32 and DOS). 106 107=item B<-formatter> I<module> 108 109Which text formatter to use. Default is L<Pod::Text>, or for very old 110Perl versions L<Pod::PlainText>. An alternative would be e.g. 111L<Pod::Text::Termcap>. 112 113=item I<file> 114 115The pathname of a file containing pod documentation to be output in 116usage message format (defaults to standard input). 117 118=back 119 120=head1 DESCRIPTION 121 122B<pod2usage> will read the given input file looking for pod 123documentation and will print the corresponding usage message. 124If no input file is specified then standard input is read. 125 126B<pod2usage> invokes the B<pod2usage()> function in the B<Pod::Usage> 127module. Please see L<Pod::Usage/pod2usage()>. 128 129=head1 SEE ALSO 130 131L<Pod::Usage>, L<pod2text(1)> 132 133=head1 AUTHOR 134 135Please report bugs using L<http://rt.cpan.org>. 136 137Brad Appleton E<lt>bradapp@enteract.comE<gt> 138 139Based on code for B<pod2text(1)> written by 140Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> 141 142=cut 143 144use Getopt::Long; 145 146## Define options 147my %options = (); 148my @opt_specs = ( 149 'help', 150 'man', 151 'exit=i', 152 'output=s', 153 'pathlist=s', 154 'formatter=s', 155 'verbose=i', 156); 157 158## Parse options 159GetOptions(\%options, @opt_specs) || pod2usage(2); 160$Pod::Usage::Formatter = $options{formatter} if $options{formatter}; 161require Pod::Usage; 162Pod::Usage->import(); 163pod2usage(1) if ($options{help}); 164pod2usage(VERBOSE => 2) if ($options{man}); 165 166## Dont default to STDIN if connected to a terminal 167pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 168 169@ARGV = ('-') unless (@ARGV); 170if (@ARGV > 1) { 171 print STDERR "pod2usage: Too many filenames given\n\n"; 172 pod2usage(2); 173} 174 175my %usage = (); 176$usage{-input} = shift(@ARGV); 177$usage{-exitval} = $options{'exit'} if (defined $options{'exit'}); 178$usage{-output} = $options{'output'} if (defined $options{'output'}); 179$usage{-verbose} = $options{'verbose'} if (defined $options{'verbose'}); 180$usage{-pathlist} = $options{'pathlist'} if (defined $options{'pathlist'}); 181 182pod2usage(\%usage); 183 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