#!/usr/bin/perl # deguten - de-gutenbergfy a file by changing newlines, removing the header, # unwordwrapping, and squashing newlines. # version 0.1 use strict; my $text; foreach (<>) { s/\r\n$/\n/; s/(.)\n/$1 /; s/^ +/ /; $text .= $_; if (/THE SMALL PRINT! FOR PUBLIC DOMAIN ETEXTS/) { $text = ""; } } $text =~ s/\n/\n\n/g; $text =~ s/\n\n\n+/\n\n/g; print $text;