Hi monks, i have written a small script to remove and add comments in a file, problem comes here is:removing comments is working but adding comments is not working, if i will run the same code separately (through command line , manually) working fine , can any one help me.
My input file test.txt consists
test test test\n
testing testing\n
test\n
testing\n
!/usr/bin/perl -w
use strict;
use warnings;
my $cmd;
my $cmd1;
$cmd = system("perl -pi -e 's/#//' test.txt"); # removing comments wor
+king
$cmd1 = system("perl -pi -e 's/(?=.*\btest\b)/#/' test.txt"); #Adding
+#'s is not working
print "$cmd \n";
print "$cmd1\n";