This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: Smoke [5.9.0] 19367 FAIL(F) MSWin32 5.0 Service Pack 3 (x86/1 cpu)
[perl5.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 (/=item (\S+)/ and $1 ne '*') {
14         s/=item //; 
15         #$cur = "POSIX::" . $1;
16         $next{$cur} = $1;
17         $cur = $1;
18         $syn{$cur} .= $_;
19         next;
20     } else { 
21         #s,L</,L<POSIX/,g;
22         s,L</,L<perlfunc/,g;
23         push @{$pod{$cur}}, $_ if $cur;
24     }
25
26
27 for $f ( keys %syn ) {
28     next unless $Type{$f};
29     $flavor = $Flavor{$f};
30     $orig = $f;
31     ($name = $f) =~ s/\W//g;
32
33     # deal with several functions sharing a description
34     $func = $orig;
35     $func = $next{$func} until $pod{$func};
36     my $body = join "", @{$pod{$func}};
37
38     # deal with unbalanced =over and =back cause by the split
39     my $has_over = $body =~ /^=over/;
40     my $has_back = $body =~ /^=back/;
41     $body =~ s/^=over\s*//m if $has_over and !$has_back;
42     $body =~ s/^=back\s*//m if $has_back and !$has_over;
43     open (POD, "> $name.pod") || die "can't open $name.pod: $!";
44     print POD <<EOF;
45 =head1 NAME
46
47 $orig - $flavor
48
49 =head1 SYNOPSIS
50
51 $syn{$orig}
52
53 =head1 DESCRIPTION
54
55 $body
56
57 EOF
58
59     close POD;
60
61