in reply to Search and replace next line
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Search and replace next line
by Anonymous Monk on Jan 05, 2005 at 10:16 UTC | |
by borisz (Canon) on Jan 05, 2005 at 10:23 UTC | |
by Thilosophy (Curate) on Jan 05, 2005 at 11:34 UTC |