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

:D Calling sed from perl is like driving a bicycle inside a car -- just drive the car

The perl oneliner equivalent (as s2p helps me understand it)

perl -i -l -p -e ' s /(.*)/Number => ${1}/s; ' test.txt

But you still don't want to use system to run that oneliner

instead use

use File::Slurp qw/ edit_file /; edit_file { s /(.*)/Number => ${1}/s; } 'test.txt';

or some such

Replies are listed 'Best First'.
Re^2: sed isn't working within a perl script
by Anonymous Monk on Oct 19, 2012 at 09:42 UTC
    You want edit_file_lines because edit_file reads the whole file and not line-by-line
Re^2: sed isn't working within a perl script
by nvivek (Vicar) on Oct 19, 2012 at 10:37 UTC
    I don't want to include new module to do this stuff. That's why, I preferred system function with sed command. Reason is I am going to add this stuff in 1000 lines of code which does other operation.