OK, I have what I need. I had several problems that I will confess for the record. While I don't think it compounded the problem, my misunderstanding of Perl's \n that tye corrected would, I'm sure, have slowed me down eventually. Second, I hadn't seen Perl's \r before, didn't recognise it at first and, for no good reason, started thinking that \n was 0D and \r was 0A. Third, I was flailing at demons and trying to sort out the \n and \r combinations in text, instead of working with hex or decimal character codes. This led to a fourth problem, namely that I was trying to resolve the difference between \n as a two character string and 0A which gets db->quoted to \n. Fifth, I was unsure about the workings of \n in regexes and tried to do it a way I understood instead of a way that worked.

My final solution is breathtakingly simple. s/\r\n/\n/g does everything I need. Even with the help I got here, it took the thick end of a day to unconfuse myself. I dread to think how long it would have taken on my own.

Plusses and kisses to all who helped! :-)

Regards,

John Davies

Update - much, much later. I continued to flail at demons even after posting the above. Strange things were happening that I could not explain and my database was not being updated. The regex I gave above, s/\r\n/\n/g, works provided there is only one line break, the case I was testing when I wrote my original query. What I really needed was s/\r\n/\n/gms to cover the case of three or more lines.


In reply to Re^4: Line separators when passing multi-line fields to a database ("\n") by davies
in thread Line separators when passing multi-line fields to a database by davies

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.