| 1 | package UnRTF; | ||||||||||
| 2 | 1 | ▶ | use Modern::Perl; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | UnRTF - A Perl wrapper around unrtf tool | ||||||||||
| 8 | |||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||
| 10 | |||||||||||
| 11 | UnRTF is a simple wrapper around unrtf command line tool, unrtf converts RTF | ||||||||||
| 12 | files to text and write it to the STDOUT. | ||||||||||
| 13 | |||||||||||
| 14 | See: L<http://www.gnu.org/software/unrtf>. | ||||||||||
| 15 | |||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||
| 17 | |||||||||||
| 18 | use UnRTF; | ||||||||||
| 19 | my $unrtf = UnRTF->new(file => "/tmp/file.rtf"); | ||||||||||
| 20 | my $text = $unrtf->convert(format => 'text'); | ||||||||||
| 21 | |||||||||||
| 22 | =head1 COPYRIGHT | ||||||||||
| 23 | |||||||||||
| 24 | Copyright (C) 2013 Joenio Costa | ||||||||||
| 25 | |||||||||||
| 26 | =cut | ||||||||||
| 27 | |||||||||||
| 28 | 1 | has file => (is => 'rw', isa => 'Str', required => 1); | |||||||||
| 29 | |||||||||||
| 30 | sub unrtf { | ||||||||||
| 31 | 2 | ▶ | open STDERR, '>', '/dev/null'; | ||||||||
|
Subroutine
unrtf: called CC=2 SCAR=10.9
Pod
undocumented
| |||||||||||
| 32 | 2 | ▶ | open(UNRTF, "unrtf @_ |") or die $!; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | local $/ = undef; | |||||||||
| 34 | 0 | my $OUTPUT = <UNRTF>; | |||||||||
| 35 | 0 | close UNRTF; | |||||||||
| 36 | 0 | $OUTPUT; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | sub convert { | ||||||||||
| 40 | 2 | ▶ | my ($self, %args) = @_; | ||||||||
|
Subroutine
convert: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 41 | 2 | unrtf("--$args{format}", $self->file); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||