in reply to Re^2: newline in unix
in thread newline in unix
<code>
</code># perl code here, with literal brackets intact: [blah]
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:
Or, if you really want to be specific about the characters you want to match:if ( /\w+.([\d.]+).\s+\w+\s+\w+/ ) { print $&, $/; }
I did try those out on your data, and the print-out includes the linefeed where it belongs.if ( /\w+.([\d.]+).\s+CURRENT\s+CHLTYPE/ ) { print $&, $/; }
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.
|
|---|