I want to slurp a file and make multiple blank lines into single blank lines. Here is my code: #! perl -w use strict; my $file = "test.fmt"; open (IN, $file) or die; open (OUT, ">>test.txt"); my $text; { local $/; $text = <IN>; close IN; } # $text =~ s/\0{2,}/\0\0/mg; # this removes all the blank lines # $text =~ s/(^$^$)(^$)+/$1/mg; # also removes all blank lines and complains # $text =~ s/(\n\n)(\n)+/$1/mg; # no improvement here either print OUT "$file\n\n$text\n******************"; close OUT;
I have tried a number of substitutions but haven't found the correct formulation. surely I am missing something simple here. Larry