You will need to modify your string and properly quote the backslash so that it gets passed correctly to the shell. I recommend the following approach:
use strict; use warnings; my $cmd = "sed -ie 's/\(.*\)/Number => \1/' test.txt"; print "Launching [$cmd]\n"; system($cmd) == 0 or die "Couldn't launch [$cmd]: $! / $?";
You will see that your single backslashes did not get passed through to the sed command. You will need to double them.
In reply to Re: sed isn't working within a perl script
by Corion
in thread sed isn't working within a perl script
by nvivek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |