Have you looked at Apache::Sandwich from CPAN? It is easy to implement
and I have used it for awhile now to add confidentiality headers and
footers to pages in a small to medium site.
cpan> m /Apache::Sandwich/
Module id = Apache::Sandwich
CPAN_USERID VKHERA (Vivek Khera <[EMAIL PROTECTED]>)
CPAN_VERSION 2.04
CPAN_FILE V/VK/VKHERA/Apache-Sandwich-2.04.tar.gz
MANPAGE Apache::Sandwich - Layered document (sandwich) maker
INST_FILE /opt/gnu/lib/perl5/site_perl/5.005/Apache/Sandwich.pm
INST_VERSION 2.04
It could most certainly be use as a basis for your needs and
requirements.
Peace.