1. First of all use three argument open with exception handling like
open(my $fh, '<', "input.txt") or die $!;2. secondly, your code is adding a new line at the bottom of the text file because you are opening a file in append mode ie., >>
use '+<' is almost always preferred for read/write updates.For more detail see http://perldoc.perl.org/functions/open.html
In reply to Re: replacing string in multi-line text file
by Nikhil Jain
in thread replacing string in multi-line text file
by jerryran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |