in reply to Re^2: How to delete a particular line in a text file after some operation on that text file at the same time
in thread How to delete a particular line in a text file after some operation on that text file at the same time
while (my $line = <$fhi>) { //Here i write the code to get the time from text file in ech li +ne and below i check in if condition if that exceed 34 hours then flu +sh that line if($Time >'34') { $fhi->autoflush; } print $fho; }
The autoflush function isn’t going to help you here. You need logic like this (untested):
while (my $line = <$fhi>) { # get $time print $fho $line unless $time > 34; }
That is: print to the output file only those lines which pass the test, and silently ignore those which don’t. And note that your statement: print $fho; needs to be changed to print $fho $line; in order to work correctly here.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to delete a particular line in a text file after some operation on that text file at the same time
by ppp (Acolyte) on Jan 18, 2015 at 05:08 UTC | |
by soonix (Chancellor) on Jan 18, 2015 at 06:48 UTC | |
by james28909 (Deacon) on Jan 18, 2015 at 06:25 UTC | |
|
Re^4: How to delete a particular line in a text file after some operation on that text file at the same time
by ppp (Acolyte) on Jan 18, 2015 at 05:36 UTC |