This is a frequent question, see also the search results for next line.while (<>) { print; if (m/TheLineBefore/){ # read the line to be replaced my $line = <>; # do something with it $line =~ s/1/0/; # print the new version print $line; } } __DATA__ test data more TheLineBefore LocalCompilerPresent=1 more stuff
In reply to Re: Search and replace next line
by Thilosophy
in thread Search and replace next line
by perlnewbie2000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |