It is easy to whip one out using Pod::Find from the Pod::Parser distribution.
The script below creates a rudimentary index file for anything it can find under my site/lib/CGI
. It is meant as a demonstration. You are probably better off with pod2html
, but this script might still be useful.
#!/usr/bin/perl
use strict; use warnings;
use autodie;
use File::Spec::Functions qw( canonpath );
use HTML::Template;
use Pod::Find qw(pod_find simplify_name);
use Pod::Select;
my $mod_top = canonpath 'c:/opt/perl/site/lib/CGI';
my $html_top = 'c:/opt/perl/html/site/lib/CGI';
my %pods = pod_find($mod_top);
my @pods;
for my $pod ( sort keys %pods ) {
(my $link = $pod) =~ s/^\Q$mod_top//;
$link =~ s/\.\w+\z//;
$link = "file:///${html_top}${link}.html";
my $name;
{
local *STDOUT;
open STDOUT, '>', \$name;
podselect({-sections => [ 'NAME' ] }, $pod);
}
$name = '' unless defined $name;
$name =~ s/^=head1\s+NAME\s+//;
$name =~ s/\s+\z//;
push @pods, {
POD => $pods{$pod},
NAME => $name,
LINK => $link,
};
}
my $tmpl = HTML::Template->new(scalarref => \ <<EO_TMPL
<!DOCTYPE HTML>
<html>
<head><title>Index of Perl Modules</title></head>
<body>
<h1><TMPL_VAR CATEGORY></h1>
<dl>
<TMPL_LOOP PODS>
<dt><a href="<TMPL_VAR LINK>"><TMPL_VAR POD></a></dt>
<dd><TMPL_VAR NAME></dd>
</TMPL_LOOP>
</ul>
</body>
</html>
EO_TMPL
);
$tmpl->param(
CATEGORY => 'CGI',
PODS => \@pods,
);
$tmpl->output(print_to => \*STDOUT);