Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: sed isn't working within a perl script

by aitap (Deacon)
on Oct 19, 2012 at 12:08 UTC ( #999915=note: print w/replies, xml ) Need Help??


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

system("sed -ie 's/\(.*\)/Number => \1/' test.txt");
See the difference:
say "sed -ie 's/\(.*\)/Number => \1/' test.txt"; say qq{sed -ie 's/\(.*\)/Number => \1/' test.txt}; say q{sed -ie 's/\(.*\)/Number => \1/' test.txt}; __END__ sed -ie 's/(.*)/Number => /' test.txt sed -ie 's/(.*)/Number => /' test.txt sed -ie 's/\(.*\)/Number => \1/' test.txt
Double quotes do interpolate your backslashes, and they are lost when you run the command. You need a non-interpolating quote operator instead to pass your string unchanded to the shell.

And I strongly advice you to use native Perl code instead, too.

Sorry if my advice was wrong.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999915]
help
Chatterbox?
[choroba]: The older one will even perform twice, once at a retirement home, and then at the music school. It's a day off, but will be pretty busy...
[Eily]: hello perlmonks :)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2017-12-12 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (327 votes). Check out past polls.

    Notices?