in reply to Re: Single newline removal when line exceeds x characters
in thread Single newline removal when line exceeds x characters

Here's one with a regex and a lookahead assertion.

local $/; $_ = <DATA>; my $wrap_min = 20; s/^(.{$wrap_min,})\n(?=\S)/$1 /gm; print; __DATA__ This is a longish line whose linebreak should be removed so that this line runs together with it. The preceding double linebreak should be conserved. This little line and this one should stay separated.

Added space after $1 thanks Roger

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Re: Single newline removal when line exceeds x characters
by Roger (Parson) on Oct 20, 2003 at 08:04 UTC
    Nice solution :-D. But you might want to add a space after $1. Otherwise the output becomes "This is a longish line whose linebreak should be removedso that this line runs together with it." where there is no space between the removed and so.