Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, i posted about inserting new lines from a text file,
so sorry about this new topic but i screwed up my last one :/
will try not to do this again.. so anyway im not sure why but after running this script a few times my file becomes empty.
open(FILE, "<myfile.txt"); my $txt = do { local $/; <FILE>}; $txt =~ s/\n{3,}/\n\n/g; close FILE; $txt =~ s/\r|\n//g; $txt =~ s/ /rand() < .5 ? ' ' : "\n"/eg; open(FILE, ">myfile.txt"); print FILE; print FILE $txt; close FILE;
Back to
Seekers of Perl Wisdom