xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/pod/podselect.PL (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/local/bin/perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse Config;
4*0Sstevel@tonic-gateuse File::Basename qw(&basename &dirname);
5*0Sstevel@tonic-gateuse Cwd;
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gate# List explicitly here the variables you want Configure to
8*0Sstevel@tonic-gate# generate.  Metaconfig only looks for shell variables, so you
9*0Sstevel@tonic-gate# have to mention them as if they were shell variables, not
10*0Sstevel@tonic-gate# %Config entries.  Thus you write
11*0Sstevel@tonic-gate#  $startperl
12*0Sstevel@tonic-gate# to ensure Configure will look for $Config{startperl}.
13*0Sstevel@tonic-gate
14*0Sstevel@tonic-gate# This forces PL files to create target in same directory as PL file.
15*0Sstevel@tonic-gate# This is so that make depend always knows where to find PL derivatives.
16*0Sstevel@tonic-gate$origdir = cwd;
17*0Sstevel@tonic-gatechdir(dirname($0));
18*0Sstevel@tonic-gate$file = basename($0, '.PL');
19*0Sstevel@tonic-gate$file .= '.com' if $^O eq 'VMS';
20*0Sstevel@tonic-gate
21*0Sstevel@tonic-gateopen OUT,">$file" or die "Can't create $file: $!";
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gateprint "Extracting $file (with variable substitutions)\n";
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate# In this section, perl variables will be expanded during extraction.
26*0Sstevel@tonic-gate# You can use $Config{...} to use Configure variables.
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gateprint OUT <<"!GROK!THIS!";
29*0Sstevel@tonic-gate$Config{'startperl'}
30*0Sstevel@tonic-gate    eval 'exec perl -S \$0 "\$@"'
31*0Sstevel@tonic-gate        if 0;
32*0Sstevel@tonic-gate!GROK!THIS!
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gate# In the following, perl variables are not expanded during extraction.
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gateprint OUT <<'!NO!SUBS!';
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate#############################################################################
39*0Sstevel@tonic-gate# podselect -- command to invoke the podselect function in Pod::Select
40*0Sstevel@tonic-gate#
41*0Sstevel@tonic-gate# Copyright (c) 1996-2000 by Bradford Appleton. All rights reserved.
42*0Sstevel@tonic-gate# This file is part of "PodParser". PodParser is free software;
43*0Sstevel@tonic-gate# you can redistribute it and/or modify it under the same terms
44*0Sstevel@tonic-gate# as Perl itself.
45*0Sstevel@tonic-gate#############################################################################
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gateuse strict;
48*0Sstevel@tonic-gateuse diagnostics;
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gate=head1 NAME
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gatepodselect - print selected sections of pod documentation on standard output
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate=head1 SYNOPSIS
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gateB<podselect> [B<-help>] [B<-man>] [B<-section>S< >I<section-spec>]
57*0Sstevel@tonic-gate[I<file>S< >...]
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate=head1 OPTIONS AND ARGUMENTS
60*0Sstevel@tonic-gate
61*0Sstevel@tonic-gate=over 8
62*0Sstevel@tonic-gate
63*0Sstevel@tonic-gate=item B<-help>
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gatePrint a brief help message and exit.
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate=item B<-man>
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gatePrint the manual page and exit.
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate=item B<-section>S< >I<section-spec>
72*0Sstevel@tonic-gate
73*0Sstevel@tonic-gateSpecify a section to include in the output.
74*0Sstevel@tonic-gateSee L<Pod::Parser/"SECTION SPECIFICATIONS">
75*0Sstevel@tonic-gatefor the format to use for I<section-spec>.
76*0Sstevel@tonic-gateThis option may be given multiple times on the command line.
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gate=item I<file>
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gateThe pathname of a file from which to select sections of pod
81*0Sstevel@tonic-gatedocumentation (defaults to standard input).
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate=back
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gate=head1 DESCRIPTION
86*0Sstevel@tonic-gate
87*0Sstevel@tonic-gateB<podselect> will read the given input files looking for pod
88*0Sstevel@tonic-gatedocumentation and will print out (in raw pod format) all sections that
89*0Sstevel@tonic-gatematch one ore more of the given section specifications. If no section
90*0Sstevel@tonic-gatespecifications are given than all pod sections encountered are output.
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gateB<podselect> invokes the B<podselect()> function exported by B<Pod::Select>
93*0Sstevel@tonic-gatePlease see L<Pod::Select/podselect()> for more details.
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gate=head1 SEE ALSO
96*0Sstevel@tonic-gate
97*0Sstevel@tonic-gateL<Pod::Parser> and L<Pod::Select>
98*0Sstevel@tonic-gate
99*0Sstevel@tonic-gate=head1 AUTHOR
100*0Sstevel@tonic-gate
101*0Sstevel@tonic-gatePlease report bugs using L<http://rt.cpan.org>.
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gateBrad Appleton E<lt>bradapp@enteract.comE<gt>
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gateBased on code for B<Pod::Text::pod2text(1)> written by
106*0Sstevel@tonic-gateTom Christiansen E<lt>tchrist@mox.perl.comE<gt>
107*0Sstevel@tonic-gate
108*0Sstevel@tonic-gate=cut
109*0Sstevel@tonic-gate
110*0Sstevel@tonic-gateuse Pod::Select;
111*0Sstevel@tonic-gateuse Pod::Usage;
112*0Sstevel@tonic-gateuse Getopt::Long;
113*0Sstevel@tonic-gate
114*0Sstevel@tonic-gate## Define options
115*0Sstevel@tonic-gatemy %options = (
116*0Sstevel@tonic-gate        "help"     => 0,
117*0Sstevel@tonic-gate        "man"      => 0,
118*0Sstevel@tonic-gate        "sections" => [],
119*0Sstevel@tonic-gate);
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate## Parse options
122*0Sstevel@tonic-gateGetOptions(\%options, "help", "man", "sections|select=s@")  ||  pod2usage(2);
123*0Sstevel@tonic-gatepod2usage(1)  if ($options{help});
124*0Sstevel@tonic-gatepod2usage(-verbose => 2)  if ($options{man});
125*0Sstevel@tonic-gate
126*0Sstevel@tonic-gate## Dont default to STDIN if connected to a terminal
127*0Sstevel@tonic-gatepod2usage(2) if ((@ARGV == 0) && (-t STDIN));
128*0Sstevel@tonic-gate
129*0Sstevel@tonic-gate## Invoke podselect().
130*0Sstevel@tonic-gateif (@{ $options{"sections"} } > 0) {
131*0Sstevel@tonic-gate    podselect({ -sections => $options{"sections"} }, @ARGV);
132*0Sstevel@tonic-gate}
133*0Sstevel@tonic-gateelse {
134*0Sstevel@tonic-gate    podselect(@ARGV);
135*0Sstevel@tonic-gate}
136*0Sstevel@tonic-gate
137*0Sstevel@tonic-gate
138*0Sstevel@tonic-gate!NO!SUBS!
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gateclose OUT or die "Can't close $file: $!";
141*0Sstevel@tonic-gatechmod 0755, $file or die "Can't reset permissions for $file: $!\n";
142*0Sstevel@tonic-gateexec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
143*0Sstevel@tonic-gatechdir $origdir;
144