in reply to accessing DOM from Perl?

Sure, you could use any HTML module to manipulate the tree structure of the web page before you serve it from the server. I recommend XML::Twig. Could you be a bit more specific about what you want?