[htmltmpl] Script under mod_perl occasionally gets garbage opening template
Brought to you by:
samtregar
From: Andy P. <ap...@gl...> - 2004-02-16 04:15:07
|
Hi, First I apologise if I'm being dense, but this problem is really confusing = the heck out of me... I've written a photo archive script using CGI::Application (ver. 3.21) and = HTML::Template (ver. 2.6), which ran fine as a standalone CGI script. Now I= 've ported it across to using mod_perl, and I'm noticing a really strange i= ntermittent problem. Basically it seems that sometimes, especially when you= request a page for the first time for a long while, when HTML::Template op= ens the .tmpl file what it gets is being somehow corrupted. This evidences = itself as an error about not recognising the TMPL_... tag - I tweaked the e= rror message slightly to print the content of the $which variable (which sh= ould hold the tag being parsed, it seems?) - this comes from line 2230: HTML::Template->new() : Unknown or unmatched TMPL construct (T0B5=20 What it *should* be printing is the contents of the $which variable in brac= kets, but it seems there are some weird control characters which trash the = rest of the string somehow (at least that's my guess). I haven't put enough= trace in to be able to tell the entire contents of the file that's being r= ead - perhaps this is just trampling the $which variable rather than the wh= ole file? In case it's useful, the line as I've amended it is: die "HTML::Template->new() : Unknown or unmatched TMPL construct ($which ) at $fname : line $fcounter."; I think what I'm doing should be fairly standard - I'm calling tmpl_path() = of CGI::Application in the cgiapp_prerun() method, and then the tmpl_load()= method later on - it's at this point the error occurs. Anyway, I realise this isn't necessarily a HTML::Template problem, but I fi= gured it was a good place to start since presumably some of you have experi= ence of using HTML::Template with mod_perl, and the potential problems. My = best guess is that somehow running the script on a newly created sub-proces= s is causing the problem, but I can't for the life of me see how - the fact= that the open succeeds, but then we get garbage later, is what baffles me. I've tried this with and without caching of templates - caching seemed to m= ake the problem happen less often, but that might have been my imagination.= Also, reloading the page a few times usually sorts the problem out, which = seems vaguely consistent with the "sub-process opening a file for the first= time" problem. Any help would be greatly appreciated, even if it's simply a more appropria= te place to redirect requests for help! Also any options to any of the code= involved to produce more helpful logs would be really handy - I'm complete= ly new to using mod_perl so I may well have fallen foul of some common trap! Cheers, - Andy ******************Legal Disclaimer************************** "This email may contain confidential and privileged material for the sole u= se of the intended recipient. Any unauthorized review, use or distribution= by others is strictly prohibited. If you have received the message in err= or, please advise the sender by reply email @globespanvirata.com, and delet= e the message. Thank you." ************************************************************ |