Debian Codegraph @

examples/text2odf

raw
1 #!/usr/bin/perl -w
2 #-----------------------------------------------------------------------------
3 # $Id : text2odf 0.2 2008-05-04 JMG$
4 #-----------------------------------------------------------------------------
5
6 =head1 NAME
7
8 text2odf - Text to OpenDocument conversion
9
10 =head1 SYNOPSIS
11
12 cat sourcefile.txt | text2odf targetfile.odt
13
14 =head1 DESCRIPTION
15
16 This filter creates an OpenDocument (ODF) file and fills it
17 with the text coming through the standard entry. The target file is
18 created, and any existing file with the same name is replaced.
19 To avoid this behaviour and append the text to an existing ODF file,
20 just remove the create => 'text' option in the script.
21
22 =cut
23
24 use OpenOffice::OODoc 2.101;
25
26 die "Missing target filename\n" unless $ARGV[0];
27 my $doc = odfDocument(file => $ARGV[0], create => 'text');
28 while (my $line = <STDIN>)
29 {
30 $doc->appendParagraph(text => $line);
31 }
32 $doc->save;
33 exit;