use strict; use warnings; my $text = do {local $/; ;}; $text =~ s/\n\n/\n/g; print $text; __DATA__ line 1 line 2 line 3 #### line 1 line 2 line 3