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