Unfortunately, there's always going to be a small cavaet to doing this, but if you can assume that a certain symbol or group of symbols will not be used by those entering the form, you can substitute that symbol(s) in for the carriage return. For example:
my $replacement = "##";
$multiline_data =~ s/\n\r?/$replacement/g;
print <OUTFILE> $multiline_data;
...
my $read_data = <INFILE>;
$read_data =~ s/$replacement/\n/g;
The problem being that if someone used '##' in their string, that would be replaced by \n on the return loop.
A better option is that you store the multiline data into it's own file separate from the flat file, the filename related to an id or the like. This way, you preserve the \n and don't have a problem with losing someone's text.
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.