Use XML::Parser to get the hashes as mentioned above for RP and MCL tags from f1 file.
Then start with f2 file and update the lines by comparing them or checking them in hashes.
I believe you need to add end_clause where you find the value of any hash once read again - for this thing keep adding the read keys in some separate data structure so that you can keep a record of read names and add end_clause
in reply to Re^6: merging a file with a value present in another file
in thread merging a file with a value present in another file