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# Copyright (c) 2001-2016 by Marek Rouchal. 43# This file is part of "Pod-Usage". Pod-Usage is free software; 44# you can redistribute it and/or modify it under the same terms 45# as Perl itself. 46############################################################################# 47 48use strict; 49#use diagnostics; 50 51=head1 NAME 52 53pod2usage - print usage messages from embedded pod docs in files 54 55=head1 SYNOPSIS 56 57=over 12 58 59=item B<pod2usage> 60 61[B<-help>] 62[B<-man>] 63[B<-exit>S< >I<exitval>] 64[B<-output>S< >I<outfile>] 65[B<-verbose> I<level>] 66[B<-pathlist> I<dirlist>] 67[B<-formatter> I<module>] 68[B<-utf8>] 69I<file> 70 71=back 72 73=head1 OPTIONS AND ARGUMENTS 74 75=over 8 76 77=item B<-help> 78 79Print a brief help message and exit. 80 81=item B<-man> 82 83Print this command's manual page and exit. 84 85=item B<-exit> I<exitval> 86 87The exit status value to return. 88 89=item B<-output> I<outfile> 90 91The output file to print to. If the special names "-" or ">&1" or ">&STDOUT" 92are used then standard output is used. If ">&2" or ">&STDERR" is used then 93standard error is used. 94 95=item B<-verbose> I<level> 96 97The desired level of verbosity to use: 98 99 1 : print SYNOPSIS only 100 2 : print SYNOPSIS sections and any OPTIONS/ARGUMENTS sections 101 3 : print the entire manpage (similar to running pod2text) 102 103=item B<-pathlist> I<dirlist> 104 105Specifies one or more directories to search for the input file if it 106was not supplied with an absolute path. Each directory path in the given 107list should be separated by a ':' on Unix (';' on MSWin32 and DOS). 108 109=item B<-formatter> I<module> 110 111Which text formatter to use. Default is L<Pod::Text>, or for very old 112Perl versions L<Pod::PlainText>. An alternative would be e.g. 113L<Pod::Text::Termcap>. 114 115=item B<-utf8> 116 117This option assumes that the formatter (see above) understands the option 118"utf8". It turns on generation of utf8 output. 119 120=item I<file> 121 122The pathname of a file containing pod documentation to be output in 123usage message format (defaults to standard input). 124 125=back 126 127=head1 DESCRIPTION 128 129B<pod2usage> will read the given input file looking for pod 130documentation and will print the corresponding usage message. 131If no input file is specified then standard input is read. 132 133B<pod2usage> invokes the B<pod2usage()> function in the B<Pod::Usage> 134module. Please see L<Pod::Usage/pod2usage()>. 135 136=head1 SEE ALSO 137 138L<Pod::Usage>, L<pod2text(1)> 139 140=head1 AUTHOR 141 142Please report bugs using L<http://rt.cpan.org>. 143 144Brad Appleton E<lt>bradapp@enteract.comE<gt> 145 146Based on code for B<pod2text(1)> written by 147Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> 148 149=cut 150 151use Getopt::Long; 152 153## Define options 154my %options = (); 155my @opt_specs = ( 156 'help', 157 'man', 158 'exit=i', 159 'output=s', 160 'pathlist=s', 161 'formatter=s', 162 'verbose=i', 163 'utf8!' 164); 165 166## Parse options 167GetOptions(\%options, @opt_specs) || pod2usage(2); 168$Pod::Usage::Formatter = $options{formatter} if $options{formatter}; 169require Pod::Usage; 170Pod::Usage->import(); 171pod2usage(1) if ($options{help}); 172pod2usage(VERBOSE => 2) if ($options{man}); 173 174## Dont default to STDIN if connected to a terminal 175pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 176 177@ARGV = ('-') unless (@ARGV); 178if (@ARGV > 1) { 179 print STDERR "pod2usage: Too many filenames given\n\n"; 180 pod2usage(2); 181} 182 183my %usage = (); 184$usage{-input} = shift(@ARGV); 185$usage{-exitval} = $options{'exit'} if (defined $options{'exit'}); 186$usage{-output} = $options{'output'} if (defined $options{'output'}); 187$usage{-verbose} = $options{'verbose'} if (defined $options{'verbose'}); 188$usage{-pathlist} = $options{'pathlist'} if (defined $options{'pathlist'}); 189$usage{-utf8} = $options{'utf8'} if (defined $options{'utf8'}); 190 191pod2usage(\%usage); 192 193 194!NO!SUBS! 195 196close OUT or die "Can't close $file: $!"; 197chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 198exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 199chdir $origdir; 200