use strict; use warnings; use diagnostics; print "START: '$str'"; $str =~ s/\n\n+/\n/g; print "\nEND: '$str'";