in reply to Perl and HTML
It sounds like you're looking for a templating system. HTML::Template will allow you to set up templates that are completed via Perl. You can even use HTML::Template to "include" templates from other files. That allows you to set up a framework template, a header template, a footer template, and so on, just pulling them all together as appropriate.
Eventually you may want to look at a more full featured framework such as Mojolicious (probably starting with a Mojolicious::Lite application). That provides templating, and a whole lot more. It helps to promote a separation of concerns (Model / View / Controller), which has become a fairly standard way of doing things, and certainly a "best practice."
Dave
In Section
Seekers of Perl Wisdom