On Mon, 10 May 2004 11:51:08 +1000, Timothy Duke wrote:

>I wish to eliminate only triple line-feeds (\n\n\n) and leave double and 
>single linefeeds, I presume <> won't work.

It will, if you set $/ to "\n\n\n". But that will not properly handle
cases of 4 or more newlines in a row.

So, perhaps you'd better switch to paragraph mode, by setting $/ to the
empty string (not undef). That way, <> will split on two or more
newlines. 

Assuming you want to replace three or more newlines with two, you can
just replace them all, by doing chomp() and appending "\n\n". If you
want to do something else with 2 than with 3+, you'll have to
distinguish these cases, perhaps by using

        s/\n{3,}$/ ??? /

where ??? is whatever you want.

docs: perlvar, -f chomp

-- 
        Bart.

Reply via email to