my $file = do { local $/; <> }; 1 while $file =~ s/^([ ]{4}[^\n]+)\n[ ]{4}/$1/m; print($file);