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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: sed isn't working within a perl script
by nvivek (Vicar) on Oct 19, 2012 at 10:39 UTC | |
Re^2: sed isn't working within a perl script
by McA (Priest) on Oct 19, 2012 at 09:19 UTC | |
by Corion (Patriarch) on Oct 19, 2012 at 09:20 UTC | |
by McA (Priest) on Oct 19, 2012 at 09:28 UTC | |
by Anonymous Monk on Oct 19, 2012 at 09:21 UTC |
In Section
Seekers of Perl Wisdom