in reply to Searching and replacing text
I expect others will propose more elegant and compact methods, but this is, I think, easy to comprehend. Note that watching for the "machine" name involves a regex match with the "i" modifier at the end, to ignore case. When expressed in perl, this approach can involve less typing than the pseudo-code I gave you.read first line from file_a split the line into scalar variables ("machine" and "site") open file_b while reading a line at a time from file_b { if the line contains "machine", set $apply_edit to true elsif the line contains "Parent Submap: " and $apply_edit is true +{ replace the rest of this line with "site" reset $apply_edit to false } print the line }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching and replacing text
by ysth (Canon) on Jul 29, 2004 at 06:06 UTC | |
by graff (Chancellor) on Jul 29, 2004 at 06:15 UTC |