fd327d80da5f0371b9ae431c044d5ea6358413c5
[p5sagit/p5-mst-13.2.git] / pod / splitpod
1 #!/usr/bin/perl
2
3 use PerlDoc::Functions;
4
5 local $/ = '';
6
7 $cur = '';
8 while (<>) {
9
10     next unless /^=(?!cut)/ .. /^=cut/;
11
12     if (s/=item (\S+)/$1/) {
13         #$cur = "POSIX::" . $1;
14         $cur = $1;
15         $syn{$cur} .= $_;
16         next;
17     } else { 
18         #s,L</,L<POSIX/,g;
19         s,L</,L<perlfunc/,g;
20         $pod{$cur} .= $_ if $cur;
21     }
22
23
24 for $f ( keys %syn ) {
25     $type = $Type{$f} || next;
26     $flavor = $Flavor{$f};
27     $orig = $f;
28     ($name = $f) =~ s/\W//g;
29     open (POD, "> $name.pod") || die "can't open $name.pod: $!";
30     print POD <<EOF;
31 =head1 NAME
32
33 $orig - $flavor
34
35 =head1 SYNOPSIS
36
37 $syn{$orig}
38
39 =head1 DESCRIPTION
40
41 $pod{$orig}
42
43 EOF
44
45     close POD;
46
47