I am writing a PERL program that will use SSI to insert affiliate code into web pages. Here is an example of the source code for a web page using this program:

... surrounding HTML ... <A HREF='http://affiliateprogram.com?id=<!--#include virtual="/cgi-bin +/affiliate.pl?option=50"-->'>Link</A> ... surrounding HTML ... ... surrounding HTML ... <A HREF='http://affiliateprogram.com?id=<!--#include virtual="/cgi-bin +/affiliate.pl?option=50&mainafil=mainaffiliateid"-->'>Link</A> ... surrounding HTML ...

People will link to the page like this:
http://www.mysite.com/page.html?affiliateid. The script affiliate.pl will use the QUERY_STRING and (QUERY_STRING_UNESCAPED || DOCUMENT_ARGS) to determine whether to return the affiliate ID from the DOCUMENT_URI or the one embedded in the "include virtual" tag.

My question is this: Given that the SSI directives could appear quite a few times in a single document, under heavy traffic loads would it be better to execute a single call that would process an entire HTML page using regular epressions to insert the affiliate code in all the right places or to go ahead and let the simple insertion script be run multiple times per page load? The advtantage to a single call is that PERL only has to run once but the script would be much more complex, processing an entire web page that could be anywhere from a few K to 40K+. With the simple SSI insertion, the script needs to be executed again and again but all it does is return a string.

I appreciate any input.

Thanks,
SpaceAce
s>>sp>;s>..|>\u$&ace>g;print;


In reply to Speed consideration by SpaceAce

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.