That may work, but that regex hurts my head. The only way I would use that code is if it were commented well as to what each part of the regex does - even then I might not use it.
A much clearer, albeit more code and more steps method, would be to:
1. read from the input file, and
2. write only lines that you want to write
to a temporary output file, and
3. close the input file
4. rename the temporary output file to the input file's
name.
This method would allow you to read ahead one (or more than one) line to see if there are 2 more more blank lines together.
Just my preference, but IMHO much clearer than trying to decifer that regex. My choice is to always make my code as understandable to *everyone* (including newbies) as possible. Obfuscated regex's do more to scare people away from Perl. Just my 2c.
HTH.