in reply to Re: Look ahead and join if the line begins with a +
in thread Look ahead and join if the line begins with a +
If you can fit all the lines and actually want to process them as separate lines then you can use a negative lookahead assertion to split just on linebreaks that aren't followed by plus signs:
{ local $/; foreach (split /\n(?!\+)/, <>) { s/\n\+/ /g; print "$_\n"; } }
Then you just have to substitute out the internal linebreaks and pluses that are left. (You may not want the space in there depending on your data.)
Note that as a side-effect, the split has chomped the input, so a \n may be needed in the output.
|
|---|