Thread POD als HTML ausgeben - wie auf search.cpan.org (4 answers)
Opened by pktm at 2012-07-18 16:54

pktm
 2012-07-19 22:52
#160081 #160081
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Hm, ich hatte erst ein bisschen gestutzt als ich die DOku gesehen habe. Aber es tut seinen Dienst :-)

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!perl

use strict;
use warnings;
use utf8;
use Pod::Html;
use Tk;
use Tk::LabEntry;
use FindBin qw/$Bin/;
use Pod::Simple::HTML;

my $mw = tkinit();

my $selection_frame = $mw->Frame()->pack(-fill => 'x');
my $e = $selection_frame->LabEntry(
-label => 'POD file:',
-labelPack => [-side => 'left'],
-bg => 'white',
)->pack(-side => 'left', -fill => 'x', -expand => 1);
my $selbtn = $selection_frame->Button(
-text => '...',
-command => sub{
my @valid_types = (
['Perl modules', '.pm'],
['POD files', '.pod'],
['All files', '*.*'],
);
my $file = $mw->getOpenFile(
-filetypes => \@valid_types,
-initialdir => $Bin,
);
if( $file ) {
# a file has been chosen
$e->delete(0, 'end');
$e->insert(0, $file);
}
},
)->pack();

my $convert_btn = $mw->Button(
-text => 'convert',
-command => sub{
my $infile = $e->get();
my $outfile = $infile . '.html';

$Pod::Simple::HTML::Content_decl = q{<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >};
my $p = Pod::Simple::HTML->new();

# -- Generated HTML will go in this variable.
# We do it this way because it's documented in the manual of Pod::Simple::HTML.
my $html = undef;

# -- This tells Pod::Simple::HTML to use $html for output.
$p->output_string(\$html);

# -- Process POD file.
$p->parse_file($infile);

# -- Open a handle to the file where we want to write the HTML to.
open( my $out, '>', $outfile ) or die("Error opening file: $!");

# -- Write the HTML in the file.
$out->print( $html );

# -- Close file handle.
close( $out );

},
)->pack(-fill => 'x',);

$mw->MainLoop();
exit(0); # exit normally (0)
http://www.intergastro-service.de (mein erstes CMS :) )

View full thread POD als HTML ausgeben - wie auf search.cpan.org