Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

HTML::Template, two warnings, part two.

by BUU (Prior)
on Apr 16, 2003 at 12:10 UTC ( [id://250861] : perlquestion . print w/replies, xml ) Need Help??

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

This is a follow up from my earlier post, but I've had much better luck narrowing it down to a simple test case. I'm using This is perl, v5.6.1 built for MSWin32-x86-multi-thread with apache 1.3.x (The one they recommend on apache.com) and HTML::Template version 2.6. All on windows XP.

Heres the perl script:
#!/usr/bin/perl require HTML::Template; my $ht=new HTML::Template(filename=>'test.tmpl'); $ht->param(testloop=>[{},{}]); print "Content-type: text/html\n\n"; print $ht->output; warn "_____TEST_____\n";

And heres the template, test.tmpl.
<html> <head> </head> <body> <tmpl_loop name='testloop'> <img src=> </tmpl_loop> </body> </html>
My error message is everytime I hit test.pl in my browser, i see two "_____TEST_____" messages in my error.log file, both with the exact same time stamps. However, if i delete the equal sign in the <img src=> or if i comment out the param call, I no longer see two warnings. Please, somebody explain this to me.

Replies are listed 'Best First'.
(jeffa) Re: HTML::Template, two warnings, part two.
by jeffa (Bishop) on Apr 16, 2003 at 14:04 UTC
    I could not recreate your test case. I am using Apache/1.3.27 (Unix) AxKit/1.6 PHP/4.2.3 mod_perl/1.27 on a RedHat box (version 2.6 of HTML::Template). Now, when you say:

    "... I no longer see two warnings."

    do you mean you only see one warning, or no warnings. Every time i ran my script, i always saw one warning in the error log. The HTML looked just like it was suppose to. I really don't see what the problem is ...

    Here is another version of your test case, one that uses DATA to store the template. I prefer to use DATA for 'self contained' test cases. Also, please use CGI::header() - but you don't have to. ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: HTML::Template, two warnings, part two.
by DrManhattan (Chaplain) on Apr 16, 2003 at 15:17 UTC

    I poked at this a bit, and my only suggestion is that perhaps it's related to either the Win32 apache or the Win32 perl you're using. I couldn't reproduce the problem on either of the unix servers I tried.

    You might try adding a __WARN__ handler. Find out if warn() is actually being called twice or if it's some issue with stderr being duplicated. E.g.

    $SIG{__WARN__} = sub { print "warn called: @_\n" };

    -Matt

Re: HTML::Template, two warnings, part two.
by Heidegger (Hermit) on Apr 16, 2003 at 15:46 UTC

    I have read your question in the morning. Recreated the situation on my Windows 2000 Perl + Apache. It happened just as you described. When you remove the '=' sign, you get only one warning. When you have it, there are two warnings in the error log ;-)

    Didn't want to post my comment in the morning, since I had no solution to it ;-)

    In a few hours perspective I think that the program you have provided looks a bit odd. I think you should fill the template variables in the template and also fill them from the code. This warning at the end also doesn't look worthwile.

      Ha! I Found the problem. Namely, an img tag with a blank src attribute causes the script to (apparently) attempt to reload itself. No clue why, but atleast i can fix it.
Re: HTML::Template, two warnings, part two.
by cfreak (Chaplain) on Apr 16, 2003 at 13:53 UTC

    I'm not 100% certain of what your asking, do you want the warnings to show up or not show up? Given the above code the warning should show up always. If its not then your program is dying sometime before it gets to that line. The reason it shows up twice I believe is due to Apache, first printing the STDERR of the CGI script in question and then printing its own log information that contains the message again.

    As for why your program could be dying, HTML::Template usually wants you to have some <tmpl_var> tags within you loop, if you don't you probably shouldn't initialize it with a $ht->param() call at all.

    Hope that helps
    Chris

    Lobster Aliens Are attacking the world!
      I'm trying to have just one warning show up. And I get the error with or without tmpl_Vars, I was just trying to condense down to the smallest test case I could.