First of all, look up Writeup Formatting Tips -- it explains how to post code coherently, which is like this:

<code>

# perl code here, with literal brackets intact: [blah]
</code>

As for the regex problem itself, now that I see what the data "really" looks like (though it's hard to be sure how many whitespace characters there really are), maybe something like this would work better:

if ( /\w+.([\d.]+).\s+\w+\s+\w+/ ) { print $&, $/; }
Or, if you really want to be specific about the characters you want to match:
if ( /\w+.([\d.]+).\s+CURRENT\s+CHLTYPE/ ) { print $&, $/; }
I did try those out on your data, and the print-out includes the linefeed where it belongs.

Now, I presume that your real goal is something other than that odd looking output from print, and depending on what your real goal is, maybe a regex isn't your best choice -- e.g. how about using split()?

update: having seen ercparker's reply below, I should point out that I was assuming all along that you already had all three lines of text stored together in $_ -- but if you've actually been reading and matching one line at a time (as most people usually do), then ercparker is right: you can't match across a newline if $_ does not contain anything after the first newline.


In reply to Re^3: newline in unix by graff
in thread newline in unix by Anonymous Monk

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.