This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlexperiment: document the private_use experiment
[perl5.git] / pod / splitpod
old mode 100755 (executable)
new mode 100644 (file)
index ff60ddc..1bc91bd
@@ -1,16 +1,23 @@
 #!/usr/bin/perl
 
-use lib '../lib';  # If you haven't installed perl yet.
+BEGIN { push @INC, '../lib' } # If you haven't installed perl yet.
 use Pod::Functions;
 
 local $/ = '';
 
+$level = 0;
+
 $cur = '';
 while (<>) {
 
     next unless /^=(?!cut)/ .. /^=cut/;
 
-    if (/=item (\S+)/ and $1 ne '*') {
+    ++$level if /^=over/;
+    --$level if /^=back/;
+
+    # Ignore items that are nested within other items, e.g. don't split on the
+    # items nested within the pack() and sprintf() items in perlfunc.pod.
+    if (/=item (\S+)/ and $level == 1) {
        my $item = $1;
        s/=item //; 
        $next{$cur} = $item;
@@ -39,17 +46,17 @@ for $f ( keys %syn ) {
     my $has_back = $body =~ /^=back/;
     $body =~ s/^=over\s*//m if $has_over and !$has_back;
     $body =~ s/^=back\s*//m if $has_back and !$has_over;
-    open (POD, "> $name.pod") || die "can't open $name.pod: $!";
+    open (POD, '>', "$name.pod") || die "can't open $name.pod: $!";
     print POD <<EOF;
-=head1 NAME
+\=head1 NAME
 
 $orig - $flavor
 
-=head1 SYNOPSIS
+\=head1 SYNOPSIS
 
 $syn{$orig}
 
-=head1 DESCRIPTION
+\=head1 DESCRIPTION
 
 $body