I want to replace some string in a file and save it back. I have already code which can open the file, find the string and replace it. But file is not getting saved. What is wrong with it?
open MYINPUTFILE, $EventLog;
my @lines = <MYINPUTFILE>; # read file into
my @errors = ();
my $size = $#lines + 1;
for ($i = 0; $i < $size; $i++) {
if ($lines[$i] =~ m/$s1(.*)$s2/) {
$lines[$i] =~ s/$s1(.*)$s2/$s1.($1+4).$s2/eg;
print $lines[$i] ;
}
}
close MYINPUTFILE;