Since you asked for a push, here's some pseudo-code, which you should be able to translate into perl:
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
}
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.