$text =~ s/(\n)*\n/$1/g; #### $text =~ s/(\n*)\n/$1/g;