This is a very basic question. I've read all the nodes on removing blank lines, but nothing is working. In fact, the code I'm posting here worked a few days ago. I don't know what I'm doing wrong.
#!/usr/bin/perl
print "What file do you want to run this program on?\n";
$TheFile=<STDIN>;
chomp ($TheFile);
open(FILE, $TheFile) or die "Can't open $TheFile.\n";
local $/ = undef;
$lines = <FILE>;
close(FILE);
while ($lines =~ /\n\n/) {
$lines =~ s/\n\n/\n/gms;
}
open(FILE, ">output.txt") or die "Can't open output.txt.\n";
print FILE $lines;
close FILE;
Can someone tell me why that doesn't work, or what should work? Thanks!