From: genericax@... (Sara) Date: 2003-12-23T06:21:54+09:00 Subject: Re: replacing two EOL chars by one tiltonj@erols.com (Jay Tilton) wrote in message news:<3fe4bd0e.68951468@news.erols.com>... > xah@xahlee.org (Xah Lee) wrote: > > : i have a bunch of java files that has spaced-out formatting that i > : want to get rid of. I want to replace two end of line characters by > : one end of line characters. The files in question is unix, and i'm > : also working under unix, so i did: > : > : perl -pi'*~' -e "s@\n\n@\n@g" *.java > : > : but this to no avail. > > Of course it's not. > > Perl's -p switch processes one line at a time. A line cannot have more > than one newline character. > > Perl's "paragraph" reading might be useful to you, where any number of > consecutive newline characters mark the end of a record. See "$/" in > perlvar for details. > > perl -i'*~' -lpe "BEGIN{$/=''}" *.java > > : after many minutes of checking and rechecking and lots of trial and > : error with frustration, i realized that the fucking perl to my > : expectations again cannot do this simple fucking thing. > > Complete nonsense. Don't blame your own incompetence on Perl. > > : Fucking stupid perl > : documentation and Larry Wall moron who is i believe incapable of > : writing clearly and logically in English masquerading as humor. > > If you feel you can explaint it more clearly, quit bellyaching about it and > submit a documentation patch. > > Preferrably one that is less petulant and profane than your article. > Frustration is no excuse for incivility. is incivility a word? Curious. Anyhow, if I understand this you want to replace two \n's with one? How about this (untested) code: die "Perl is ever so much smarter than Java\n" unless open F, 'myfile'; my @f = close F; $f = join '',@f; $f =~ s/(\n)\n/$1/gs; die "Hmm this file cant be opened for writing\n" unless open F, '>myfile'; print F $f; close F; print "Perl does it again!\n\n";