http://www.perlmonks.org?node_id=999885


in reply to sed isn't working within a perl script

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.