in reply to CGI within your layout

There are several SSI modules on CPAN that will simulate SSI for your CGI scripts. Look at CGI::SSI or CGI::SSI_Parser for starters.