In a message dated 5/10/2004 12:22:06 AM Eastern Daylight Time, 
[EMAIL PROTECTED] writes:
>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?
>
>[codes snipped]
>

Working off your sample code, how about:

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

-will 
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite 

-- 
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