
Tricky column formatting/space removing question
I'm parsing data inputted via an html form. $body=multiline textual data of
arbitrary length. I want to preserve the paragraph separations, while
making the lines themselves 80 columns in length. At the same time, I am
contending with white space at the beginning of each line, of abitrary lenth.
Here's what I've kludged together so far:
$body =~ s/\n\s*/\n/g; ## Get rid of multiple spaces that follow a new line.
$body =~ s/^\s*//g; ## Gets rid of the initial space missed by prev regex
(That ain't pretty, but it works... anyone got a better way??)
new Text::Format->columns(80); # Set Column width to 80
$body=new Text::Format->format($body); # Standardize paragraphs to 80 chars
The problem is, this concatenates all of the pre-existing paragraphs into a
single large uber paragraph.
How can I fold the long lines, merge the short lines, but preserve the extra
CR/LF's between paragraphs?
Any help appreciate...
--
.............................................................................
"The Israeli objective since 1967 has been to transform the ethnic character
of the annexed area [of East Jerusalem] from Arab to Jewish. Israeli
demolition policy in East Jerusalem is based on similar premises as in the
rest of the West Bank: construction of settlements restricted to Jews,
confiscation of land for exclusively Jewish use, and restriction and
demolition of Palestinian development."
-Amnesty International Report:
"The Destruction of Palestinian Homes"
December 8, 1999.
.............................................................................