File: podprune

package info (click to toggle)
lavaps 2.7-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,824 kB
  • ctags: 1,190
  • sloc: cpp: 6,382; sh: 3,227; ansic: 1,649; tcl: 707; makefile: 312; perl: 202
file content (74 lines) | stat: -rwxr-xr-x 1,560 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/perl -w

#
# podprune
# $Id: podprune,v 1.2 1999/09/14 04:29:50 johnh Exp $
#
# Copyright (C) 1999 by John Heidemann
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#



sub usage {
    print STDERR <<END;
usage: $0 [-k] sections

Omit (or keep with -k) the given sections of a pod file
which is read from standard input.
END
    exit 1;
}

use strict;

use Getopt::Long;
&usage if ($#ARGV >= 0 && $ARGV[0] eq '-?');
my(%opts);
&GetOptions(\%opts, qw(k));
&usage if ($#ARGV < 0);

my(%omit, %keep);
my($default_status) = !defined($opts{'k'});
my($section, $kept) = ("", "");

foreach (@ARGV) {
    if ($default_status) {
	$omit{lc($_)} = 1;
    } else {
	$keep{lc($_)} = 1;
    };
};

sub handle {
    if (defined($keep{$section}) || (!defined($omit{$section}) && $default_status)) {
	print $kept;
    };
}

while (<STDIN>) {
    if (/^=head1\s+(.*)$/) {
	&handle;
	$section = lc($1);
	$kept = $_;
    } else {
	$kept .= $_;
    };
};

&handle;

exit 0;