Installation on Win32
[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
5b3c99c0 13 if (/=item (\S+)/ and $1 ne '*') {
14 s/=item //;
cb1a09d0 15 #$cur = "POSIX::" . $1;
40d50c58 16 $next{$cur} = $1;
cb1a09d0 17 $cur = $1;
18 $syn{$cur} .= $_;
19 next;
20 } else {
21 #s,L</,L<POSIX/,g;
22 s,L</,L<perlfunc/,g;
40d50c58 23 push @{$pod{$cur}}, $_ if $cur;
cb1a09d0 24 }
25}
26
27for $f ( keys %syn ) {
40d50c58 28 next unless $Type{$f};
cb1a09d0 29 $flavor = $Flavor{$f};
30 $orig = $f;
31 ($name = $f) =~ s/\W//g;
40d50c58 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
3e3baf6d 38 # deal with unbalanced =over and =back cause by the split
3e3baf6d 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;
cb1a09d0 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
3e3baf6d 55$body
cb1a09d0 56
57EOF
58
59 close POD;
60
61}