# App::PerldocServer use autopackage; use strict; use warnings FATAL => 'all'; use 5.16.2; use EV; use AnyEvent::HTTPD; use File::Basename qw(basename dirname); use Pod::Simple::HTML; use URI::Escape qw(uri_unescape); sub new { bless {} } sub run { my $self = shift; my $httpd = AnyEvent::HTTPD->new( port => 8877 ); $httpd->reg_cb( '' => sub { my ($httpd, $req) = @_; my $path = $req->url()->path(); my $m = uri_unescape(basename($path)); $httpd->stop_request(); my $f = $self->find_module($m); my $html; if ($f) { local $Pod::Simple::HTML::Perldoc_URL_Prefix = ('http://localhost:8877' . dirname($path) . '/') =~ s[/+$][/]r; my $p = Pod::Simple::HTML->new(); $p->output_string(\$html); $p->parse_file($f); } else { $html = "