Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

pod2rtf

by jmcnamara (Monsignor)
on Oct 16, 2002 at 16:13 UTC ( #205756=snippet: print w/ replies, xml ) Need Help??

Description: Simple pod2rtf (Rich Text Format) converter based on the Pod::Simple::RTF subclass of Pod::Simple.

See also pod2rtf.

Usage: pod2rtf [infile] [outfile] If infile isn't defined defaults to STDIN If outfile isn't defined defaults to STDOUT
#!/usr/bin/perl -w

use strict;
use Pod::Simple::RTF;


my $parser = Pod::Simple::RTF->new();


if (defined $ARGV[0]) {
    open IN, $ARGV[0] or die "Couldn't open $ARGV[0]: $!\n";
} else {
    *IN = *STDIN;
}

if (defined $ARGV[1]) {
    open OUT, ">$ARGV[1]" or die "Couldn't open $ARGV[1]: $!\n";
} else {
    *OUT = *STDOUT;
}


$parser->output_fh(*OUT);
$parser->parse_file(*IN);


__END__

Comment on pod2rtf
Download Code
Re: pod2rtf
by casiano (Pilgrim) on Apr 18, 2009 at 08:21 UTC
    Thanks for the script.

    I have experienced problems when converting files containing utf8 characters (like spanish accents, etc.). The alternative was to convert the file first to isolatin:

    #!/usr/bin/perl -w use strict; use Pod::Simple::RTF; my $file = shift || die "Provide a file name\n"; die "Provide a file name\n" unless -r $file; my $latin = $file; $latin = "$file.latin"; my $parser = Pod::Simple::RTF->new(); my $outfile = $file; $outfile =~ s/\.\w*$/.rtf/ or $outfile = "$file.rtf"; open STDOUT, "> $outfile"; system("iconv -f UTF-8 -t ISO_8859-15 $file > $latin") and die "Can't +execute iconv\n"; Pod::Simple::RTF->filter($latin)->any_errata_seen; unlink $latin;

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://205756]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (19)
As of 2015-07-07 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (89 votes), past polls