RE: [htmltmpl] mod_perl usage
Brought to you by:
samtregar
From: Paulsen, B. <BPa...@le...> - 2006-03-07 14:59:40
|
To expound a bit more on the "use strict;" line... The big difference between mod_perl and normal CGI execution is that in mod_perl, the forked child Apache process is used to serve up content. In normal CGI execution, a separate process is forked off and that is used. If you have global variables in your script, it doesn't matter in normal CGI execution because those are cleaned up when the forked process exits. In mod_perl, since there is no forked subprocess, global variables never get cleaned up. Instead, they are reused the next time that the script is executed. So, if you have something where your variables are undeclared and uninitialized, it will appear that mod_perl is caching old values for you. Having the "use strict;" line forces you to declare your variables, which usually puts them in a local scope. =46WIW, all of my CGI scripts look like this... use strict; sub printPage { ... Do all my processing here... } printPage; -----Original Message----- =46rom: htm...@li... [mailto:htm...@li...] On Behalf Of Matthew Boehm Sent: Tuesday, March 07, 2006 9:44 AM To: htm...@li... Subject: Re: [htmltmpl] mod_perl usage Here is some debug information. What follows is 3 attempts at my CGI.=20 =46irst was with the companyID of 1 (Traders International) 2nd was ID 26 (Trading Zoo) and 3rd was ID 2 (omNovia). Notice that the #3 attempt shows the same values from attempt #1 and that #3's debug output is MUCH less than the other 2. So who is caching this=3F Sounds like mod_perl is. This is bad. apologies for line wrapping.. Thanks, Matthew **** attempt #1 **** ### HTML::Template Debug ### In _parse: ### HTML::Template Debug ### /templates/background.tpl : line 1 :=20 TMPL_IF login_menu start ### HTML::Template Debug ### /templates/background.tpl : line 2 :=20 INCLUDE login_menu.tpl ### HTML::Template Debug ### /templates/login_menu.tpl : line 1 : parsed VAR header ### HTML::Template Debug ### /templates/login_menu.tpl : line 13 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 17 :=20 parsed VAR companyname ### HTML::Template Debug ### /templates/login_menu.tpl : line 22 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 23 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 31 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 32 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 35 :=20 parsed VAR footer ### HTML::Template Debug ### /templates/background.tpl : line 2 :=20 /TMPL_IF end ### HTML::Template Debug ### /templates/background.tpl : line 4 :=20 TMPL_IF login_page start ### HTML::Template Debug ### /templates/background.tpl : line 5 :=20 INCLUDE login_page.tpl ### HTML::Template Debug ### /templates/background.tpl : line 5 :=20 /TMPL_IF end ### HTML::Template _param Stack Dump ### bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::NOOP' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), msg.innerHTML =3D "Your subscription expires in " + daysTillExpired + " days. " + document.getElementById(\'popupinfo\').innerHTML +=3D " <span style=3D\\"font-weight: bold; color: #FF0000;\\">Dual Windows disabled due to popup blocker.</span>"; _javarow.innerHTML =3D _html; r.innerHTML =3D "<font color=3Dred " + fSize + "><b>" + t + "</b></font>" + addedTxt; c.innerHTML =3D "<b>Event Name:</b>" + sText; c.innerHTML=3D""; ### HTML::Template Cache Debug ### CACHE LOAD :=20 /templates/background.tpl =3D> a3b4215ada4a08b236710034cb1dd9c3 ### HTML::Template Debug ### In output ### HTML::Template output Stack Dump ### bless( do{\(my $o =3D 1)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), bless( do{\(my $o =3D '<!DOCTYPE HTML PUBLIC \'-//W3C//DTD HTML 4.01 Transitional//EN\' \'http://www.w3.org/TR/html4/loose.dtd\'> <td>')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D '1')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D 'Traders International')}, 'HTML::Template::VAR' ), </html>')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::NOOP' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), msg.innerHTML =3D "Your subscription expires in " + daysTillExpired + " days. " + document.getElementById(\'popupinfo\').innerHTML +=3D " <span style=3D\\"font-weight: bold; color: #FF0000;\\">Dual Windows disabled due to popup blocker.</span>"; _javarow.innerHTML =3D _html; r.innerHTML =3D "<font color=3Dred " + fSize + "><b>" + t + "</b></font>" + addedTxt; c.innerHTML =3D "<b>Event Name:</b>" + sText; c.innerHTML=3D""; **** attempt #2 ****** ### HTML::Template Debug ### In _parse: ### HTML::Template Debug ### /templates/background.tpl : line 1 :=20 TMPL_IF login_menu start ### HTML::Template Debug ### /templates/background.tpl : line 2 :=20 INCLUDE login_menu.tpl ### HTML::Template Debug ### /templates/login_menu.tpl : line 1 : parsed VAR header ### HTML::Template Debug ### /templates/login_menu.tpl : line 13 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 17 :=20 parsed VAR companyname ### HTML::Template Debug ### /templates/login_menu.tpl : line 22 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 23 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 31 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 32 :=20 parsed VAR companyid ### HTML::Template Debug ### /templates/login_menu.tpl : line 35 :=20 parsed VAR footer ### HTML::Template Debug ### /templates/background.tpl : line 2 :=20 /TMPL_IF end ### HTML::Template Debug ### /templates/background.tpl : line 4 :=20 TMPL_IF login_page start ### HTML::Template Debug ### /templates/background.tpl : line 5 :=20 INCLUDE login_page.tpl ### HTML::Template Debug ### /templates/background.tpl : line 5 :=20 /TMPL_IF end ### HTML::Template _param Stack Dump ### bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::NOOP' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), msg.innerHTML =3D "Your subscription expires in " + daysTillExpired + " days. " + document.getElementById(\'popupinfo\').innerHTML +=3D " <span style=3D\\"font-weight: bold; color: #FF0000;\\">Dual Windows disabled due to popup blocker.</span>"; _javarow.innerHTML =3D _html; r.innerHTML =3D "<font color=3Dred " + fSize + "><b>" + t + "</b></font>" + addedTxt; c.innerHTML =3D "<b>Event Name:</b>" + sText; c.innerHTML=3D""; ### HTML::Template Cache Debug ### CACHE LOAD :=20 /templates/background.tpl =3D> a3b4215ada4a08b236710034cb1dd9c3 ### HTML::Template Debug ### In output ### HTML::Template output Stack Dump ### bless( do{\(my $o =3D 1)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), bless( do{\(my $o =3D '<!DOCTYPE HTML PUBLIC \'-//W3C//DTD HTML 4.01 Transitional//EN\' \'http://www.w3.org/TR/html4/loose.dtd\'> <td>')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D '26')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D 'TradingZoo')}, 'HTML::Template::VAR' ), </html>')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::NOOP' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), msg.innerHTML =3D "Your subscription expires in " + daysTillExpired + " days. " + document.getElementById(\'popupinfo\').innerHTML +=3D " <span style=3D\\"font-weight: bold; color: #FF0000;\\">Dual Windows disabled due to popup blocker.</span>"; _javarow.innerHTML =3D _html; r.innerHTML =3D "<font color=3Dred " + fSize + "><b>" + t + "</b></font>" + addedTxt; c.innerHTML =3D "<b>Event Name:</b>" + sText; c.innerHTML=3D""; ******* attempt #3 ****** ### HTML::Template Cache Debug ### CACHE HIT :=20 /some/path//pages/sctest/templates/background.tpl =3D> a3b4215ada4a08b236710034cb1dd9c3 ### HTML::Template Debug ### In output ### HTML::Template output Stack Dump ### bless( do{\(my $o =3D 1)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), bless( do{\(my $o =3D '<!DOCTYPE HTML PUBLIC \'-//W3C//DTD HTML 4.01 Transitional//EN\' \'http://www.w3.org/TR/html4/loose.dtd\'> <td>')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D '1')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D 'Traders International')}, 'HTML::Template::VAR' ), </html>')}, 'HTML::Template::VAR' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::NOOP' ), bless( do{\(my $o =3D undef)}, 'HTML::Template::VAR' ), ], 'HTML::Template::COND' ), msg.innerHTML =3D "Your subscription expires in " + daysTillExpired + " days. " + document.getElementById(\'popupinfo\').innerHTML +=3D " <span style=3D\\"font-weight: bold; color: #FF0000;\\">Dual Windows disabled due to popup blocker.</span>"; _javarow.innerHTML =3D _html; r.innerHTML =3D "<font color=3Dred " + fSize + "><b>" + t + "</b></font>" + addedTxt; c.innerHTML =3D "<b>Event Name:</b>" + sText; c.innerHTML=3D""; ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel=3Fcmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users ---------------------------------------------------------------------------= --- This message is intended only for the personal and confidential use of the = designated recipient(s) named above. If you are not the intended recipient= = of this message you are hereby notified that any review, dissemination, = distribution or copying of this message is strictly prohibited. This = communication is for information purposes only and should not be regarded a= s= an offer to sell or as a solicitation of an offer to buy any financial = product, an official confirmation of any transaction, or as an official = statement of Lehman Brothers. Email transmission cannot be guaranteed to b= e= secure or error-free. Therefore, we do not represent that this informatio= n= is complete or accurate and it should not be relied upon as such. All = information is subject to change without notice. |