in reply to update a value in xml file
I strongly second the consensus that your workflow should move from &ldqo;one so-called generation of input files,” which will emerge completely unchanged, to produce “one complete generation of new output-files, which are completely replaced. You design the workflow so that you are always producing new generations of the entire collection of files. Keep the old ones... disks are big and cheap, and pkzip works now just as well as it ever did. This gives you a completely repeatable process, with a history and with the capability to re-run at any point.
For the actual XML processing, use a powerful package like XML::Twig, and get to know (and use well) “XPath expressions.” Beware: Do not treat an XML file as “text,” and do not write an algorithm that cannot be shown to work correctly in the general case. (The mere fact that “it seems to work with the data that I tried” doesn’t cut it.)