Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: remove single blank lines?

by aloomens (Initiate)
on Dec 09, 2003 at 18:44 UTC ( [id://313479]=note: print w/replies, xml ) Need Help??


in reply to remove single blank lines?

What I've settle on is shown below. It won't remove a single blank line at the beginning of the file, but I don't need that. It may not be the most efficient way to do this, but it make sense to me. I learned a bunch. Thanks!
#!/usr/bin/perl while (<>) { $last = $this; $this = $next; $next = $_; $lastblank = ($last =~ (/^\s*$/)); $thisblank = ($this =~ (/^\s*$/)); $nextblank = ($next =~ (/^\s*$/)); print $this unless (! $lastblank) && ($thisblank) && (! $nextblank); } print $next unless ($nextblank) && (! $thisblank);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found