[differences between cumulative patch application and perl5.004_01]
[p5sagit/p5-mst-13.2.git] / pod / splitpod
1 #!/usr/bin/perl
2
3 use lib '../lib';  # If you haven't installed perl yet.
4 use Pod::Functions;
5
6 local $/ = '';
7
8 $cur = '';
9 while (<>) {
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;
21         push @{$pod{$cur} ||= []}, $_ if $cur;
22     }
23
24
25 for $f ( keys %syn ) {
26     $type = $Type{$f} || next;
27     $flavor = $Flavor{$f};
28     $orig = $f;
29     ($name = $f) =~ s/\W//g;
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;
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
48 $body
49
50 EOF
51
52     close POD;
53
54