#! perl5 # # sglspc.pl Daniel Brockman 20030307 cvt dblspc to sglspc # # Usage: perl -- sglspc.pl < inputfile > outputfile ################################################ # The author grants permission to use for any # # purpose, including copying and modification, # # provided the user acknowledges the author by # # name. # # -- Daniel Brockman, author, 20031220 # ################################################ # # $prev=1; # 0=space, 1=nonspace, 2=prev part of continued line while ($line=<>) { # BIG LOOP $line=~s/[ \t]+\n/\n/g ; # remove trailing white space $linx=$line ; $linx=~s/[ \t\n]+//g ; if($linx=~m/^$/){ # it's a blank line if($prev==1) { # prev line nonblank? go on to next. $prev=0; # we hit insignificant blank next; # get next line } print "$line"; # otherwise, print it $prev=1; # its a significant blank next; # and go on }else{ # nonblank print "$line"; # print it $prev=1; } } # end while BIG LOOP #