Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: remove single blank lines?

by asarih (Hermit)
on Dec 08, 2003 at 22:32 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-18 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found