in reply to Re^3: Search and replace next line
in thread Search and replace next line

You seem to have trouble opening the file. Perl can do this for you. Try this:
while (<>) { print; if (m/Gimpel PC-Lint for H8\]/){ # read the line to be replaced my $line = <>; # do something with it $line =~ s/1/0/; # print the new version print $line; } }
and run it as "perl replace_test.pl Compiler_Setup.ini". If the output looks okay, use "perl -i replace_test.pl Compiler_Setup.ini"

Replies are listed 'Best First'.
Re^5: Search and replace next line
by Anonymous Monk on Jan 05, 2005 at 12:19 UTC
    So instead of opening the file like I do: perl "replace test.pl" then write: perl "replace test.pl Compiler_Setup.ini" and then it will open the file Compiler_setup so that I can read lines out of it? NICE :D
    and if I set the -i attrib it will change the line LocalCompilerPresent=0 in Compiler_Setup.ini to =1 ??

    Sorry for asking this many questions, I just want to know that I got it right :) I'm quite new to perl, but I think it's fun.. :)
      I just tried it now, but it says Can't do inplace edit without backup at test.pl line 1. how do I fix that?