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