Write to the middle of a file in Perl
Answer:
To write to the middle of a text file, can be easily performed by Perl.
Assume the file has 10 lines, you want to replace the 5th line:
#!/usr/bin/perl
use strict;
use Tie::File;
my $file = 'foo.txt';
tie @array, 'Tie::File', $file or die "Cannot open $file \n";
@array[4] = "Replaced!\n";
That's easy?