in reply to SSI help...

I've been through a similar process trying to get layout scripts to work with both static and cms-generated pages, and i don't really recommend the post-parsing approach. Apart from anything else, you're going through the whole inefficient cgi process twice.

It's going to be much easier and more efficient if you modularise your code a bit.

Put the ad script in a module. In the simplest case it'll all be in a single sub called make_ad(), or something like that. Then replace your ads.cgi script with a very short one:

#!usr/bin/perl; use Ads::Mymodule; print "Content-type:text/html\n\n"; print Ads::make_ad(); exit;

You may need to pass parameters to the sub, of course. You can then use the same mechanism in your serve.cgi. Where you used to say:

print qq|<!--#exec cmd="/cgi-bin/ads/ads.cgi"-->|;

and then parse it out again and run the ad script, all you need is:

print Ads::make_ad();

And the outcome is the same: no extra steps and no duplication of code. There are good tutorials around for module-building, including perldoc perlmod.

Incidentally, the included ads.cgi needs to print the mime-type header on Apache, but not on IIS, as i recall.