Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在目录中生成Perl模块或脚本的HTML摘要?_Perl_Perl Pod - Fatal编程技术网

如何在目录中生成Perl模块或脚本的HTML摘要?

如何在目录中生成Perl模块或脚本的HTML摘要?,perl,perl-pod,Perl,Perl Pod,有没有工具可以在目录树中生成perl模块或脚本的HTML摘要列表 给定 我想看看像这样的东西 <a href="docsforwibble">wibble.pl</a> - does wibble actions <a href="docsforwobble">wobble.pl</a> - does wobble actions -wibble是否执行操作 -摆动动作会发生吗 使用发行版中的 下面的脚本为它在my站点/lib/CGI下可以找到的

有没有工具可以在目录树中生成perl模块或脚本的HTML摘要列表

给定

我想看看像这样的东西

<a href="docsforwibble">wibble.pl</a> - does wibble actions
<a href="docsforwobble">wobble.pl</a> - does wobble actions
-wibble是否执行操作
-摆动动作会发生吗

使用发行版中的

下面的脚本为它在my
站点/lib/CGI
下可以找到的任何内容创建了一个基本索引文件。这是一种示范。使用
pod2html
可能会更好,但此脚本可能仍然有用

#!/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);
#/usr/bin/perl
严格使用;使用警告;
使用自动模具;
使用File::Spec::Functions qw(canonpath);
使用HTML::模板;
使用Pod::Find qw(Pod_Find simplify_name);
使用Pod::Select;
my$mod_top=canopath'c:/opt/perl/site/lib/CGI';
my$html_top='c:/opt/perl/html/site/lib/CGI';
我的%pods=pod\u find($mod\u top);
我的@pods;
对于我的$pod(排序键%pods){
(my$link=$pod)=~s/^\Q$mod_top/;
$link=~s/\.\w+\z/;
$link=“file://${html\u top}${link}.html”;
我的$name;
{
本地*STDOUT;
打开标准输出“>”,\$name;
podselect({-sections=>['NAME']},$pod);
}
$name='',除非定义了$name;
$name=~s/^=head1\s+name\s+/;
$name=~s/\s+\z/;
推动@pods{
POD=>$pods{$POD},
NAME=>$NAME,
LINK=>$LINK,
};
}
我的$tmpl=HTML::Template->new(scalarref=>\'CGI',
豆荚=>\@PODS,
);
$tmpl->输出(打印到=>\*STDOUT);
pod2html--recurse--podpath


请参见

这似乎只适用于
.pod
文件,或者我遗漏了什么?您首先如何递归创建pod文件?感谢@Sinan,这看起来像是我正在寻找的东西。
#!/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);