#!/usr/bin/env perl # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # This Perl script improves the formatting of Project Gutenberg .txt files # for use with the Amazon Kindle. # # Paul Gorman (http://paulgorman.org) # Created 21 April 2008 # Modified 22 April 2008 # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (@ARGV != 1) { die "Wrong number of arguments. See the README at http://paulgorman.org/software/gutenberg_to_kindle/README.txt.\n" } $paragraph = ''; while (<>) { if ($_ =~ m/^(\n|\r|\f)$/) { # New paragraph starts. print ' ' . $paragraph . "\n"; $paragraph = ''; } else { $_ =~ s/\r//; # Get rid of DOS-style line breaks. chomp; $paragraph .= ' ' . $_; } }