Just to nitpick a tiny bit, I want to warn about your
modification to $/.
By doing things the way to did, you are
setting yourself up for crazy-ass bugs. You properly localize the
variable, but the scope of the localization is way too broad.
I suggest getting in the habit of anonymous blocks every time you
localize a global variable. Like This:
open OUT, ">fixed" or die "Couldn't open fixed: $!";
open IN, "<junk" or die "Couldn't open junk: $!";
{
local $/ = undef;
($_ = <IN>) =~ s/\n{2,}/\n/g;
print OUT;
}
close IN;
close OUT;
This way you properly limit the scope of
local $/ to just the lines you need it. And wont accidentilly screw yourself
up later.