Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: remove single blank lines?

by asarih (Hermit)
on Dec 08, 2003 at 22:32 UTC ( #313282=note: print w/replies, xml ) Need Help??


in reply to remove single blank lines?

If the file you want to examine does not fit in memory, you will have to remember two lines at a time.
while (<>) { print unless ($_ eq "\n") && ($last ne "\n") && ($secondlast ne "\n" +); $secondlast = $last; $last = $_; }
update: This doesn't quite work. We'll have to deter deciding whether or not we will print the current line until we have examined the next line.
while (<>) { $last = $this; $this = $next; $next = $_; print $this unless ($last ne "\n") && ($this eq "\n") && ($next ne " +\n"); } print $next unless ($next eq "\n") && ($this ne "\n"); #last line is s +pecial

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2022-08-08 19:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?