I googled and found this: <!--#exec cgi="ssi.demo.cgi"--> from
http://www.weijers.net/guide/ssi.shtml#exec. The CGI::SSI documentation for the exec function looks as though it might execute the included script with environment intact.
I have no way of testing this so please reply if it all works out!