in reply to page break at paragraph break

If you don't mind losing some whitespace (blank lines) you could do it like this:
#!/usr/bin/perl -w use strict; use constant LPP => 63; # for enscript my @chunk; my $line = 0; $/ = ''; while ( <> ) { if ( $line + y/\n// >= LPP ) { print "\n" x ( LPP - $line ); $line = 0; } print; $line += y/\n//; }

Replies are listed 'Best First'.
Re^2: page break at paragraph break
by dbw (Beadle) on Jul 31, 2007 at 14:52 UTC
    Well, a file might have lines of tab, followed by a blank line, followed by a line of lyrics, followed by two blanks, followed by more tab. Mangling the whitespace could make this confusing.