Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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??

Help for this page

Select Code to Download


  1. or download this
    while (<>) {
      print unless ($_ eq "\n") && ($last ne "\n") && ($secondlast ne "\n"
    +);
      $secondlast = $last;
      $last = $_;
    }
    
  2. or download this
    while (<>) {
      $last = $this;
    ...
      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 surveying the Monastery: (5)
As of 2022-09-28 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (124 votes). Check out past polls.

    Notices?