typo in change#3768
[p5sagit/p5-mst-13.2.git] / pod / podselect.PL
CommitLineData
360aca43 1#!/usr/local/bin/perl
2
3use Config;
4use File::Basename qw(&basename &dirname);
5
6# List explicitly here the variables you want Configure to
7# generate. Metaconfig only looks for shell variables, so you
8# have to mention them as if they were shell variables, not
9# %Config entries. Thus you write
10# $startperl
11# to ensure Configure will look for $Config{startperl}.
12
b233458b 13$file = basename($0);
14$file =~ s/\.PL$//i;
15$file .= '.com' if $^O eq 'VMS';
360aca43 16
b233458b 17chdir("pod") or die "Can't chdir to pod: $!";
360aca43 18open OUT,">$file" or die "Can't create $file: $!";
19
20print "Extracting $file (with variable substitutions)\n";
21
22# In this section, perl variables will be expanded during extraction.
23# You can use $Config{...} to use Configure variables.
24
25print OUT <<"!GROK!THIS!";
26$Config{'startperl'}
27 eval 'exec perl -S \$0 "\$@"'
28 if 0;
29!GROK!THIS!
30
31# In the following, perl variables are not expanded during extraction.
32
33print OUT <<'!NO!SUBS!';
34
35#############################################################################
36# podselect -- command to invoke the podselect function in Pod::Select
37#
38# Derived from Tom Christiansen's pod2text script.
39# (with extensive modifications)
40#
41# Copyright (c) 1996 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;
48use diagnostics;
49
50=head1 NAME
51
52podselect - print selected sections of pod documentation on standard output
53
54=head1 SYNOPSIS
55
56B<podselect> [B<-help>] [B<-man>] [B<-section>S< >I<section-spec>]
57[I<file>S< >...]
58
59=head1 OPTIONS AND ARGUMENTS
60
61=over 8
62
63=item B<-help>
64
65Print a brief help message and exit.
66
67=item B<-man>
68
69Print the manual page and exit.
70
71=item B<-section>S< >I<section-spec>
72
73Specify a section to include in the output.
74See L<Pod::Parser/"SECTION SPECIFICATIONS">
75for the format to use for I<section-spec>.
76This option may be given multiple times on the command line.
77
78=item I<file>
79
80The pathname of a file from which to select sections of pod
81documentation (defaults to standard input).
82
83=back
84
85=head1 DESCRIPTION
86
87B<podselect> will read the given input files looking for pod
88documentation and will print out (in raw pod format) all sections that
89match one ore more of the given section specifications. If no section
90specifications are given than all pod sections encountered are output.
91
92B<podselect> invokes the B<podselect()> function exported by B<Pod::Select>
93Please see L<Pod::Select/podselect()> for more details.
94
95=head1 SEE ALSO
96
97L<Pod::Parser> and L<Pod::Select>
98
99=head1 AUTHOR
100
101Brad Appleton E<lt>bradapp@enteract.comE<gt>
102
103Based on code for B<Pod::Text::pod2text(1)> written by
104Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
105
106=cut
107
108use Pod::Select;
109use Pod::Usage;
110use Getopt::Long;
111
112## Define options
113my %options = (
114 "help" => 0,
115 "man" => 0,
116 "sections" => [],
117);
118
119## Parse options
120GetOptions(\%options, "help", "man", "sections|select=s@") || pod2usage(2);
121pod2usage(1) if ($options{help});
122pod2usage(-verbose => 2) if ($options{man});
123
124## Dont default to STDIN if connected to a terminal
125pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
126
127## Invoke podselect().
128if (@{ $options{"sections"} } > 0) {
129 podselect({ -sections => $options{"sections"} }, @ARGV);
130}
131else {
132 podselect(@ARGV);
133}
134
135
136!NO!SUBS!
137
138close OUT or die "Can't close $file: $!";
139chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
140exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';