Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: remove single blank lines?

by hmerrill (Friar)
on Dec 08, 2003 at 22:23 UTC ( [id://313276]=note: print w/replies, xml ) Need Help??


in reply to Re: remove single blank lines?
in thread remove single blank lines?

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://313276]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-29 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found