I am perl bginner (but i guess logic is same for all programming languages like C++ and C in my case its perl).
What i want to achieve ?
I have a text file i read that file which contains different IPaddress Time in each line and when i find a particular Time then i delete that line.
What is the problem ?
The problem is when i open a file and check for time (to see that is this the particular time i am looking for to delete this line) then it need to read that file (I mean '<' operation) but when i have to delete that particular line after finding that correct time i need to do write operation (I mean this '>' operation). Now when i try to achieve this i use this code (which will surely not work as the file is opened in read mode we cannot delete (i mean write to it)):
open my $fhi, '<', 'C:\shekhar_Axestrack_Intern\WindowCreation\ListOfIpAdress.txt', or die "Could not open file $!";
while (my $line = <$fhi>)
{
## Doing some operation using $fhi in read mode
if($Time >'33')
{
$fhi->autoflush; #flush the line if time is greater than 33 hours, whereas all other lines which do not folow the condition are still present in file.
}
}
close $fhi;
How to delete that particular line in text file (after some manupulation of time ?)