here is a link to some thing that may help.
https://www.unix.com/showthread.php?s...&highlight=sed
You could just as easily use sed instead of perl. Also, your match may be failing. It is possible that when you capture the value for $i that it is not matching properly.
Also I would try executing the sed/perl statement from the command line to see what it does there.
Here is my attempt. Here is my input file and the output after I execute the command line.
Every other line has a # in it...
/root> cat toddfile
# This is a test
This is a test
# This is a test
This is a test
# This is a test
This is a test
# This is a test
This is a test
# This is a test
Here is the execution of the command line and output...
root> sed -e 's/\#/Not-Implimented/' toddfile
Not-Implimented This is a test
This is a test
Not-Implimented This is a test
This is a test
Not-Implimented This is a test
This is a test
Not-Implimented This is a test
This is a test
Not-Implimented This is a test
Now that I look at your script, I think that the "grep" is the problem.