http://qs1969.pair.com?node_id=313282


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