[differences between cumulative patch application and perl5.004_01]
[p5sagit/p5-mst-13.2.git] / pod / splitpod
CommitLineData
cb1a09d0 1#!/usr/bin/perl
2
6ec7a3ca 3use lib '../lib'; # If you haven't installed perl yet.
4use Pod::Functions;
cb1a09d0 5
6local $/ = '';
7
8$cur = '';
9while (<>) {
10
11 next unless /^=(?!cut)/ .. /^=cut/;
12
13 if (s/=item (\S+)/$1/) {
14 #$cur = "POSIX::" . $1;
15 $cur = $1;
16 $syn{$cur} .= $_;
17 next;
18 } else {
19 #s,L</,L<POSIX/,g;
20 s,L</,L<perlfunc/,g;
3e3baf6d 21 push @{$pod{$cur} ||= []}, $_ if $cur;
cb1a09d0 22 }
23}
24
25for $f ( keys %syn ) {
26 $type = $Type{$f} || next;
27 $flavor = $Flavor{$f};
28 $orig = $f;
29 ($name = $f) =~ s/\W//g;
3e3baf6d 30 # deal with unbalanced =over and =back cause by the split
31 my $body = $pod{$orig};
32 my $has_over = $body =~ /^=over/;
33 my $has_back = $body =~ /^=back/;
34 $body =~ s/^=over\s*//m if $has_over and !$has_back;
35 $body =~ s/^=back\s*//m if $has_back and !$has_over;
cb1a09d0 36 open (POD, "> $name.pod") || die "can't open $name.pod: $!";
37 print POD <<EOF;
38=head1 NAME
39
40$orig - $flavor
41
42=head1 SYNOPSIS
43
44$syn{$orig}
45
46=head1 DESCRIPTION
47
3e3baf6d 48$body
cb1a09d0 49
50EOF
51
52 close POD;
53
54}