One possible way to handle this would be to use HTML::Template. It offers you the ability to use include statements within your HTML code. So, using your example, you could do something like:
And then of course, audio.html and video.html would contain all the HTML code for those particular sections.
There are other templating systems though. Here is a node that describes various templating systems
. Template Toolkit may end up being more powerful in the end, but I find it easier to keep presentation/code seperated using HTML::Template. So check em both out and decide :-)