in reply to Editing Links

Yes, there are too-many interpretations of your question to enable any one of us to figure out exactly what it is you are asking...

When HTML files are produced, they are usually produced using a templating system such as (for example...) Template Toolkit.

When you are dealing with a (well-formed) HTML file, a good way to approach the problem is to grab an HTML-parser, which will turn the HTML file into a tree. Then, a tool like XML::XPath will let you "query" that tree and find the particular points you want to change. Change them, then convert the tree back into an HTML output.