in reply to ssi within perl

Apache's SSI processor does not work on the output of CGI scripts. You need to use one of emulation modules from CPAN, like CGI::SSI.