in reply to Adding sessionid to all links in HTML-document

Your question is a little vague. Do you mean adding it to every tag? Like <i sessionid="asdf"/>? Because that would be invalid HTML. Or add it to the arguments in src like attributes, like <form action="...?sid=asdf"/> and <a href="...?sid=asdf"/>?

Either way the solution is almost certainly based off a parser like HTML::TokeParser. HTML is better handled (accuracy and speed) by parsers for anything robust. If you provide more info or show what you've tried, you'll probably get a decent snippet or two here.