http://qs321.pair.com?node_id=240206

SpaceAce has asked for the wisdom of the Perl Monks concerning the following question:

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;