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 }