1
#############################################################################
2
# Select.pm -- function to select portions of pod docs
4
# Based on Tom Christiansen's pod2text() function
5
# (with extensive modifications).
7
# Copyright (C) 1996 Tom Christiansen. All rights reserved.
8
# This file is part of "PodParser". PodParser is free software;
9
# you can redistribute it and/or modify it under the same terms
11
#############################################################################
13
package PDL::Pod::Select;
15
$VERSION = 1.00; ## Current version of this package
16
require 5.002; ## requires Perl version 5.002 or later
20
podselect - function to extract selected sections of pod documentation
25
podselect (@filelist);
26
podselect ({OUTPUT => "tmp.out"}, @filelist):
27
podselect ({SELECT => ["NAME|SYNOPSIS", "OPTIONS"]}, @filelist):
28
podselect ({OUTPUT => ">&STDERR", SELECT => ["DESCRIPTION"]}, "-");
32
B<podselect()> is a function which will extract specified sections of
33
pod documentation from an input stream. This ability is already provided
34
in the B<PDL::Pod::Parser> module. Subclasses of B<PDL::Pod::Parser> that wish to
35
take advantage of this feature do I<not> need to derive from
36
B<PDL::Pod::Select>. B<PDL::Pod::Select> merely provides a single function named
37
B<podselect()> which provides this capability in function form (as
38
opposed to object form) for extracting the raw pod docs.
42
#############################################################################
47
@EXPORT = qw(&podselect);
59
=head2 podselect(\%options, @filelist)
61
B<podselect> will print the raw (untranslated) pod documentation of all
62
pod sections in the given input files specified by C<@filelist>
63
according to the given options.
65
If any argument to B<podselect> is a reference to a hash
66
(associative array) then the values with the following keys are
73
A string corresponding to the desired output file (or ">&STDOUT"
74
or ">&STDERR"). The default is to use standard output.
78
A reference to an array of sections specifications (as described in
79
L<PDL::Pod::Parser/"SECTION SPECIFICATIONS">) which indicate the desired set of pod
80
sections and subsections to be selected from input. If no section
81
specifications are given, then all sections of pod documentation are
86
All other arguments should correspond to the names of input files
87
containing pod documentation. A file name of "-" or "<&STDIN" will
88
be interpeted to mean standard input (which is the default if no
95
my (@sections, $output);
96
my $pod_parser = new PDL::Pod::Parser;
101
next unless (ref($_) eq 'HASH');
102
$output = $_->{OUTPUT} if (defined $_->{OUTPUT});
103
if ((defined $_->{SELECT}) && (ref($_->{SELECT}) eq 'ARRAY')) {
104
$pod_parser->select(@{$_->{SELECT}});
108
$pod_parser->parse_from_file($_, $output);
112
$pod_parser->parse_from_file("-") unless ($num_inputs > 0);
121
Brad Appleton E<lt>Brad_Appleton-GBDA001@email.mot.comE<gt>
123
Based on code for B<pod2text> written by
124
Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>