From what you are saying I would suggest looking at something like HTML::Template. This would allow you to seperate out the HTML/Javascript from the perl side. This is especially useful when you are receiving constantly updated html from 3rd parties.
Hope this helps
UnderMine