続 POD をブラウザで閲覧する
たとえば mod_perl2 だと以下のような感じのハンドラになります(テストスクリプトも POD もないですが)。
package Podview; use strict; use Apache2::Const -compile => qw(:common); use Apache2::RequestRec (); use Apache2::RequestIO (); use Pod::HtmlEasy; use Pod::Perldoc; sub handler : method { my $class = shift; my $r = shift; my ($path_info, $location); my ($pkg_name, $pod_path, $html); my $converter; $location = $r->location; if ($location) { $path_info = $r->uri; $path_info =~ s|${location}||; } else { $path_info = $r->path_info; } for ($path_info) { s'(::|//+)'/'go; s'^/''o; } $pod_path = find_pod_path($path_info); unless ($pod_path) { return Apache2::Const::NOT_FOUND; } $pkg_name = $path_info; $pkg_name =~ s'/'::'go; $converter = Pod::HtmlEasy->new( on_L => sub { my ($this, $L, $text, $page, $section, $type) = @_; if ($type eq 'pod') { $section = "#${section}" if $section ne ''; $page =~ s'::'/'go; return qq|<i><a href="${location}/${page}${section}">${text}</a></i>|; } elsif ($type eq 'man') { return qq|<i>${text}</i>|; } elsif ($type eq 'url') { return qq|<a href="${page}" target="_blank">${text}</a>|; } }, ); $html = $converter->pod2html( $pod_path, '', title => "podview: ${pkg_name}", basic_entities => 1, no_generator => 1, ); unless ($html) { return Apache2::Const::NOT_FOUND; } $html =~ s'charset=iso-8859-1'charset=UTF-8'io; $r->content_type('text/html; charset=UTF-8'); $r->print($html); return Apache2::Const::OK; } sub find_module_path { return _find_module_or_pod($_[0], 1); } sub find_pod_path { return _find_module_or_pod($_[0], 0); } sub _find_module_or_pod { my ($pod, $opt_m) = @_; my $pd = Pod::Perldoc->new(); $pd->opt_l(1); $pd->opt_m($opt_m) if ($opt_m); my @pages = ( $pod ); my @found = $pd->grand_search_init(\@pages); return join('', @found); } 1;
使い方は,
<Location /perldoc> SetHandler perl-script PerlResponseHandler Podview </Location>
として,http://〜/perldoc/CGI/Cookie をアクセス,のように,「::」は「/」に変換してください。