#!/usr/bin/perl
BEGIN {
push
@INC
,
'../lib'
}
local
$/ =
''
;
$level
= 0;
$cur
=
''
;
while
(<>) {
next
unless
/^=(?!cut)/ .. /^=cut/;
++
$level
if
/^=over/;
--
$level
if
/^=back/;
if
(/=item (\S+)/ and
$level
== 1) {
my
$item
= $1;
s/=item //;
$next
{
$cur
} =
$item
;
$cur
=
$item
;
$syn
{
$cur
} .=
$_
;
next
;
}
else
{
s,L</,L<perlfunc/,g;
push
@{
$pod
{
$cur
}},
$_
if
$cur
;
}
}
for
$f
(
keys
%syn
) {
next
unless
$Type
{
$f
};
$flavor
=
$Flavor
{
$f
};
$orig
=
$f
;
(
$name
=
$f
) =~ s/\W//g;
$func
=
$orig
;
$func
=
$next
{
$func
}
until
$pod
{
$func
};
my
$body
=
join
""
, @{
$pod
{
$func
}};
my
$has_over
=
$body
=~ /^=over/;
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: $!"
;
print
POD
<<EOF;
\=head1 NAME
$orig - $flavor
\=head1 SYNOPSIS
$syn{$orig}
\=head1 DESCRIPTION
$body
EOF
close
POD;
}