in reply to Re^3: inserting new lines
in thread inserting new lines

well the code that was posted by the other member (or you?) was actually a better idea, only problem is that after running the script a few times the file becomes empty.
#open file removing empty lines open(FILE, "<myfile.txt"); my $txt = do { local $/; <FILE>}; $txt =~ s/\n{3,}/\n\n/g; close FILE; #remove new lines $txt =~ s/\r|\n//g; #insert newlines after a randomly selected space $txt =~ s/ /rand() < .5 ? ' ' : "\n"/eg; open(FILE, ">myfile.txt"); print FILE; print FILE $txt; close FILE;