191f110e0Safresh1#!/usr/local/bin/perl 291f110e0Safresh1 3*eac174f2Safresh1use strict; 4*eac174f2Safresh1use warnings; 591f110e0Safresh1use Config; 691f110e0Safresh1use File::Basename qw(&basename &dirname); 791f110e0Safresh1use Cwd; 891f110e0Safresh1 991f110e0Safresh1# List explicitly here the variables you want Configure to 1091f110e0Safresh1# generate. Metaconfig only looks for shell variables, so you 1191f110e0Safresh1# have to mention them as if they were shell variables, not 1291f110e0Safresh1# %Config entries. Thus you write 1391f110e0Safresh1# $startperl 1491f110e0Safresh1# to ensure Configure will look for $Config{startperl}. 1591f110e0Safresh1 1691f110e0Safresh1# This forces PL files to create target in same directory as PL file. 1791f110e0Safresh1# This is so that make depend always knows where to find PL derivatives. 18*eac174f2Safresh1my $origdir = cwd; 1991f110e0Safresh1chdir( dirname($0) ); 20*eac174f2Safresh1my $file = basename( $0, '.PL' ); 2191f110e0Safresh1$file .= '.com' if $^O eq 'VMS'; 2291f110e0Safresh1 23*eac174f2Safresh1open my $OUT, '>', $file or die "Can't create $file: $!"; 2491f110e0Safresh1 2591f110e0Safresh1print "Extracting $file (with variable substitutions)\n"; 2691f110e0Safresh1 2791f110e0Safresh1# In this section, perl variables will be expanded during extraction. 2891f110e0Safresh1# You can use $Config{...} to use Configure variables. 2991f110e0Safresh1 30*eac174f2Safresh1print {$OUT} <<"!GROK!THIS!"; 3191f110e0Safresh1$Config{'startperl'} 3291f110e0Safresh1 eval 'exec perl -S \$0 "\$@"' 3391f110e0Safresh1 if 0; 3491f110e0Safresh1!GROK!THIS! 3591f110e0Safresh1 3691f110e0Safresh1# In the following, perl variables are not expanded during extraction. 3791f110e0Safresh1 38*eac174f2Safresh1print {$OUT} <<'!NO!SUBS!'; 3991f110e0Safresh1 4091f110e0Safresh1############################################################################# 4191f110e0Safresh1# pod2usage -- command to print usage messages from embedded pod docs 4291f110e0Safresh1# 4391f110e0Safresh1# Copyright (c) 1996-2000 by Bradford Appleton. All rights reserved. 44b8851fccSafresh1# Copyright (c) 2001-2016 by Marek Rouchal. 45b8851fccSafresh1# This file is part of "Pod-Usage". Pod-Usage is free software; 4691f110e0Safresh1# you can redistribute it and/or modify it under the same terms 4791f110e0Safresh1# as Perl itself. 4891f110e0Safresh1############################################################################# 4991f110e0Safresh1 5091f110e0Safresh1use strict; 5191f110e0Safresh1#use diagnostics; 5291f110e0Safresh1 5391f110e0Safresh1=head1 NAME 5491f110e0Safresh1 5591f110e0Safresh1pod2usage - print usage messages from embedded pod docs in files 5691f110e0Safresh1 5791f110e0Safresh1=head1 SYNOPSIS 5891f110e0Safresh1 5991f110e0Safresh1=over 12 6091f110e0Safresh1 6191f110e0Safresh1=item B<pod2usage> 6291f110e0Safresh1 6391f110e0Safresh1[B<-help>] 6491f110e0Safresh1[B<-man>] 6591f110e0Safresh1[B<-exit>S< >I<exitval>] 6691f110e0Safresh1[B<-output>S< >I<outfile>] 6791f110e0Safresh1[B<-verbose> I<level>] 6891f110e0Safresh1[B<-pathlist> I<dirlist>] 6991f110e0Safresh1[B<-formatter> I<module>] 70b8851fccSafresh1[B<-utf8>] 7191f110e0Safresh1I<file> 7291f110e0Safresh1 7391f110e0Safresh1=back 7491f110e0Safresh1 7591f110e0Safresh1=head1 OPTIONS AND ARGUMENTS 7691f110e0Safresh1 7791f110e0Safresh1=over 8 7891f110e0Safresh1 7991f110e0Safresh1=item B<-help> 8091f110e0Safresh1 8191f110e0Safresh1Print a brief help message and exit. 8291f110e0Safresh1 8391f110e0Safresh1=item B<-man> 8491f110e0Safresh1 8591f110e0Safresh1Print this command's manual page and exit. 8691f110e0Safresh1 8791f110e0Safresh1=item B<-exit> I<exitval> 8891f110e0Safresh1 8991f110e0Safresh1The exit status value to return. 9091f110e0Safresh1 9191f110e0Safresh1=item B<-output> I<outfile> 9291f110e0Safresh1 9391f110e0Safresh1The output file to print to. If the special names "-" or ">&1" or ">&STDOUT" 9491f110e0Safresh1are used then standard output is used. If ">&2" or ">&STDERR" is used then 9591f110e0Safresh1standard error is used. 9691f110e0Safresh1 9791f110e0Safresh1=item B<-verbose> I<level> 9891f110e0Safresh1 9991f110e0Safresh1The desired level of verbosity to use: 10091f110e0Safresh1 10191f110e0Safresh1 1 : print SYNOPSIS only 10291f110e0Safresh1 2 : print SYNOPSIS sections and any OPTIONS/ARGUMENTS sections 10391f110e0Safresh1 3 : print the entire manpage (similar to running pod2text) 10491f110e0Safresh1 10591f110e0Safresh1=item B<-pathlist> I<dirlist> 10691f110e0Safresh1 10791f110e0Safresh1Specifies one or more directories to search for the input file if it 10891f110e0Safresh1was not supplied with an absolute path. Each directory path in the given 10991f110e0Safresh1list should be separated by a ':' on Unix (';' on MSWin32 and DOS). 11091f110e0Safresh1 11191f110e0Safresh1=item B<-formatter> I<module> 11291f110e0Safresh1 11391f110e0Safresh1Which text formatter to use. Default is L<Pod::Text>, or for very old 11491f110e0Safresh1Perl versions L<Pod::PlainText>. An alternative would be e.g. 11591f110e0Safresh1L<Pod::Text::Termcap>. 11691f110e0Safresh1 117b8851fccSafresh1=item B<-utf8> 118b8851fccSafresh1 119b8851fccSafresh1This option assumes that the formatter (see above) understands the option 120b8851fccSafresh1"utf8". It turns on generation of utf8 output. 121b8851fccSafresh1 12291f110e0Safresh1=item I<file> 12391f110e0Safresh1 12491f110e0Safresh1The pathname of a file containing pod documentation to be output in 125*eac174f2Safresh1usage message format. If omitted, standard input is read - but the 126*eac174f2Safresh1output is then formatted with L<Pod::Text> only - unless a specific 127*eac174f2Safresh1formatter has been specified with B<-formatter>. 12891f110e0Safresh1 12991f110e0Safresh1=back 13091f110e0Safresh1 13191f110e0Safresh1=head1 DESCRIPTION 13291f110e0Safresh1 13391f110e0Safresh1B<pod2usage> will read the given input file looking for pod 13491f110e0Safresh1documentation and will print the corresponding usage message. 13591f110e0Safresh1If no input file is specified then standard input is read. 13691f110e0Safresh1 13791f110e0Safresh1B<pod2usage> invokes the B<pod2usage()> function in the B<Pod::Usage> 13891f110e0Safresh1module. Please see L<Pod::Usage/pod2usage()>. 13991f110e0Safresh1 14091f110e0Safresh1=head1 SEE ALSO 14191f110e0Safresh1 142*eac174f2Safresh1L<Pod::Usage>, L<pod2text>, L<Pod::Text>, L<Pod::Text::Termcap>, 143*eac174f2Safresh1L<perldoc> 14491f110e0Safresh1 14591f110e0Safresh1=head1 AUTHOR 14691f110e0Safresh1 14791f110e0Safresh1Please report bugs using L<http://rt.cpan.org>. 14891f110e0Safresh1 14991f110e0Safresh1Brad Appleton E<lt>bradapp@enteract.comE<gt> 15091f110e0Safresh1 15191f110e0Safresh1Based on code for B<pod2text(1)> written by 15291f110e0Safresh1Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> 15391f110e0Safresh1 15491f110e0Safresh1=cut 15591f110e0Safresh1 15691f110e0Safresh1use Getopt::Long; 15791f110e0Safresh1 15891f110e0Safresh1## Define options 15991f110e0Safresh1my %options = (); 16091f110e0Safresh1my @opt_specs = ( 16191f110e0Safresh1 'help', 16291f110e0Safresh1 'man', 16391f110e0Safresh1 'exit=i', 16491f110e0Safresh1 'output=s', 16591f110e0Safresh1 'pathlist=s', 16691f110e0Safresh1 'formatter=s', 16791f110e0Safresh1 'verbose=i', 168b8851fccSafresh1 'utf8!' 16991f110e0Safresh1); 17091f110e0Safresh1 17191f110e0Safresh1## Parse options 17291f110e0Safresh1GetOptions(\%options, @opt_specs) || pod2usage(2); 17391f110e0Safresh1$Pod::Usage::Formatter = $options{formatter} if $options{formatter}; 17491f110e0Safresh1require Pod::Usage; 17591f110e0Safresh1Pod::Usage->import(); 17691f110e0Safresh1pod2usage(1) if ($options{help}); 17791f110e0Safresh1pod2usage(VERBOSE => 2) if ($options{man}); 17891f110e0Safresh1 17991f110e0Safresh1## Dont default to STDIN if connected to a terminal 18091f110e0Safresh1pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 18191f110e0Safresh1 18291f110e0Safresh1if (@ARGV > 1) { 18391f110e0Safresh1 print STDERR "pod2usage: Too many filenames given\n\n"; 18491f110e0Safresh1 pod2usage(2); 18591f110e0Safresh1} 18691f110e0Safresh1 18791f110e0Safresh1my %usage = (); 188*eac174f2Safresh1$usage{-input} = shift(@ARGV) || \*STDIN; 18991f110e0Safresh1$usage{-exitval} = $options{'exit'} if (defined $options{'exit'}); 19091f110e0Safresh1$usage{-output} = $options{'output'} if (defined $options{'output'}); 19191f110e0Safresh1$usage{-verbose} = $options{'verbose'} if (defined $options{'verbose'}); 19291f110e0Safresh1$usage{-pathlist} = $options{'pathlist'} if (defined $options{'pathlist'}); 193b8851fccSafresh1$usage{-utf8} = $options{'utf8'} if (defined $options{'utf8'}); 19491f110e0Safresh1 19591f110e0Safresh1pod2usage(\%usage); 19691f110e0Safresh1 19791f110e0Safresh1 19891f110e0Safresh1!NO!SUBS! 19991f110e0Safresh1 200*eac174f2Safresh1close($OUT) or die "Can't close $file: $!"; 201*eac174f2Safresh1chmod( 0755, $file ) or die "Can't reset permissions for $file: $!\n"; 20291f110e0Safresh1exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 203*eac174f2Safresh1chdir($origdir); 204