I'll tell you, as a user of editors, I don't want my newlines changed. I run Linux and when I edit a windows file, I'm doing it for a good reason and I want the new newlines to be the same as the newlines that were there when I opened the file. Which is what happens with both emacs and gedit. If that's not what happens, I look for a new editor.

As far as detecting the value of \n, I think you're trying too hard not to reinvent the wheel. Deciding which of the 3 endings a file uses is, imho, a job for a regex, not a module.

Personally, I've never encountered a file where mixed newline types would be anything be a corrupt file. For fun, I'll imagine printing a file for a win client out of a mod_perl module that runs on linux. Well, the windows EOL would be contained in quotes and/or escaped so the obvious *NIX dominance should prevail. Of course, I could be missing an important use case here.

That said, an option to convert EOL to various formats would be a nice option to offer.


In reply to Re: maintaining newlines in file by rowdog
in thread maintaining newlines in file by szabgab

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.