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 | 17 | chdir(dirname($0)); |
8478abc4 CB |
18 | $file = basename($0, '.PL'); |
19 | $file .= '.com' if $^O eq 'VMS'; | |
360aca43 GS |
20 | |
21 | open OUT,">$file" or die "Can't create $file: $!"; | |
22 | ||
23 | print "Extracting $file (with variable substitutions)\n"; | |
24 | ||
25 | # In this section, perl variables will be expanded during extraction. | |
26 | # You can use $Config{...} to use Configure variables. | |
27 | ||
28 | print OUT <<"!GROK!THIS!"; | |
29 | $Config{'startperl'} | |
30 | eval 'exec perl -S \$0 "\$@"' | |
31 | if 0; | |
32 | !GROK!THIS! | |
33 | ||
34 | # In the following, perl variables are not expanded during extraction. | |
35 | ||
36 | print OUT <<'!NO!SUBS!'; | |
37 | ||
38 | ############################################################################# | |
39 | # podselect -- command to invoke the podselect function in Pod::Select | |
40 | # | |
92e3d63a | 41 | # Copyright (c) 1996-2000 by Bradford Appleton. All rights reserved. |
360aca43 GS |
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 | ||
47 | use strict; | |
48 | use diagnostics; | |
49 | ||
50 | =head1 NAME | |
51 | ||
52 | podselect - print selected sections of pod documentation on standard output | |
53 | ||
54 | =head1 SYNOPSIS | |
55 | ||
56 | B<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 | ||
65 | Print a brief help message and exit. | |
66 | ||
67 | =item B<-man> | |
68 | ||
69 | Print the manual page and exit. | |
70 | ||
71 | =item B<-section>S< >I<section-spec> | |
72 | ||
73 | Specify a section to include in the output. | |
9c6ed6d7 | 74 | See L<Pod::Parser/"SECTION SPECIFICATIONS"> |
360aca43 GS |
75 | for the format to use for I<section-spec>. |
76 | This option may be given multiple times on the command line. | |
77 | ||
78 | =item I<file> | |
79 | ||
80 | The pathname of a file from which to select sections of pod | |
81 | documentation (defaults to standard input). | |
82 | ||
83 | =back | |
84 | ||
85 | =head1 DESCRIPTION | |
86 | ||
87 | B<podselect> will read the given input files looking for pod | |
88 | documentation and will print out (in raw pod format) all sections that | |
89 | match one ore more of the given section specifications. If no section | |
90 | specifications are given than all pod sections encountered are output. | |
91 | ||
92 | B<podselect> invokes the B<podselect()> function exported by B<Pod::Select> | |
93 | Please see L<Pod::Select/podselect()> for more details. | |
94 | ||
95 | =head1 SEE ALSO | |
96 | ||
97 | L<Pod::Parser> and L<Pod::Select> | |
98 | ||
99 | =head1 AUTHOR | |
100 | ||
aaa799f9 NC |
101 | Please report bugs using L<http://rt.cpan.org>. |
102 | ||
360aca43 GS |
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 ':'; | |
933fea7f | 143 | chdir $origdir; |