Hi,

I have got two versions of a script to eliminate single line-feeds from a file. The first one does weird stuff - duplicating lines and messing the text file up. The second one works (I copied it from a Perl guide), but I don't understand why. I would much prefer the first one to work - Can you tell me how to change the first one to make it work?

Also, I understand that the <> operator reads in one line at a time. If I wish to eliminate only triple line-feeds (\n\n\n) and leave double and single linefeeds, I presume <> won't work. Without reading in the whole file at once, how can I achieve this?

I am using MacPerl.

Thanks for any help!

Tim

----------------------------------------------------

Version #1 (works dreadfully....stuffs up the file)

#! perl  -w -i
$filetobechanged = "iBook HD:Desktop Folder:tim.txt";
open(FILE, "+< $filetobechanged") ;
while (<FILE>) {
    s/\n//g;
    print FILE ;
        }
close(FILE);


Version #2 (works fine) $filetobechanged = "iBook HD:Desktop Folder:tim.txt"; @ARGV = ($filetobechanged); $^I = ".bak"; while (<>) { s/\n//g;; print; }


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to