sub view_source my self my params c- req- params- to_hash my module pa

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sub view_source {
my ($self, $c) = @_;
my $params = $c->req->params->to_hash;
my $module = $params->{module};
my $stash = { template => 'perl/index.html', from => 'view_source', IS_WIN32 => IS_WIN32 };
if ( $module ) {
# find the HTML place of a module
my $file = `perldoc -l $module`;
#$c->app->log->debug("perldoc -l $module return $file");
my $code = "Can't find $module";
if ( $file ) {
chomp( $file );
$code = eval { File::Slurp::read_file($file, binmode => ':raw') };
$code = "# $file\n\n$code";
$code = $@ if $@;
}
$stash->{content} = $code;
}
$c->view( $stash );
}