Uh, if the page is already being 'dynamically generated' (from the cgi script), why not just have it insert the text? HTML::Template might help.
Note that he is correct, in that the output of a script is not parsed for ssi commands. You can however force that with the use of the the ssi-chain module somewhere on cpan