Yes. This might be what you mean:
$string =~ s/\n//;
That will remove the first newline it sees. When mixing platforms you might have to deal with \r also. If you want to remove all the newlines add a g switch:
$string =~ s/\n//g;
Consider replacing the newline with something smaller, like a space.

So newline is a single character (at least on unix) and you can match it with \n.

Phil

Update: Hue-Bond pointed out an error in wording. The issue with \r arrises when you process a file on a different system than the one that generated it. Generally \n will match whatever the native new line combination is, but it will not necessarily match if the file came from a foreign system.


In reply to Re: Remove Carriage Return by philcrow
in thread Remove Carriage Return by icg

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.