Deleting a line from a huge file in Perl
<p>I have huge text file and first five lines of it reads as below :</p>

<pre><code>This is fist line
This is second line
This is third line
This is fourth line
This is fifth line
</code></pre>

<p>Now, I want to write something at a random position of the third line of that file which will replace the characters in that line by the new string I am writing. I am able to achieve that with the below code :</p>

<pre><code>use strict;
use warnings;

my @pos = (0);
open my $fh, "+&lt;", "text.txt";

while(&lt;$fh) {
    push @pos, tell($fh);
}

seek $fh , $pos[2]+1, 0;
print $fh "HELLO";

close($fh);
</code></pre>

<p>However, I am not able to figure out with the same kind of approach how can I delete the entire third line from that file so that the texts reads below :</p>

<pre><code>This is fist line
This is second line
This is fourth line
This is fifth line
</code></pre>

<p>I do not want to read the entire file into an array, neither do I want to use Tie::File. Is it possible to achieve my requirement using seek and tell ? A solution will be very helpful. </p>