The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/perl -w
#-----------------------------------------------------------------------------
# $Id : text2odf 0.2 2008-05-04 JMG$
#-----------------------------------------------------------------------------
=head1 NAME
text2odf - Text to OpenDocument conversion
=head1 SYNOPSIS
cat sourcefile.txt | text2odf targetfile.odt
=head1 DESCRIPTION
This filter creates an OpenDocument (ODF) file and fills it
with the text coming through the standard entry. The target file is
created, and any existing file with the same name is replaced.
To avoid this behaviour and append the text to an existing ODF file,
just remove the create => 'text' option in the script.
=cut
use OpenOffice::OODoc 2.101;
die "Missing target filename\n" unless $ARGV[0];
my $doc = odfDocument(file => $ARGV[0], create => 'text');
while (my $line = <STDIN>)
{
$doc->appendParagraph(text => $line);
}
$doc->save;
exit;