vr786 has asked for the wisdom of the Perl Monks concerning the following question:
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: System command problem in perl
by jwkrahn (Abbot) on Nov 26, 2010 at 15:19 UTC | |
|
Re: System command problem in perl
by mjscott2702 (Pilgrim) on Nov 26, 2010 at 12:50 UTC | |
|
Re: System command problem in perl
by Anonymous Monk on Nov 26, 2010 at 12:01 UTC | |
by tod222 (Pilgrim) on Nov 26, 2010 at 21:07 UTC |