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.


In reply to Re: SSI help... by thpfft
in thread SSI help... by EvanK

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.