#!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{}; 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)