My problem is basically that the following script appears to be executing twice, as i get two warnings (_____INDEX.PL______) in my apache error log every time i view a page. This was causing some interesting problems. I tried to narrow down the script to produce a small test case illustrating it, but quite frankly I've had absolutely no luck. So i turn to you fine monks.
Here is the script itself:
#!/usr/bin/perl use strict; use CGI::Carp qw/fatalsToBrowser/; binmode STDIN; use lib 'mods'; require CGI::Lite; require HTML::Template; require DBI; require User; $::dbh=DBI->connect('dbi:mysql:movies','name'); $::ht=new HTML::Template(filename => 'tmpl/default.tmpl'); $::c=new CGI::Lite; $::c->set_directory('uploads'); $::c->set_file_type('file'); %::f=$::c->parse_form_data('GET'); $::f{f}=shift if(~~@ARGV); $::user=new User; my %dispatch= ( news => 'news', add_news => 'add_news', add_news_submit => 'add_news_submit', login => 'login', login_submit => 'login_submit', movie => 'movie', me => 'me', ); if(not $::f{o}) {$::f{o}='news';} warn "_____INDEX.PL______"; #do "subs/$dispatch{$::f{o}}.pl" if($dispatch{$::f{o}}); defaultTmplData(); print "Content-type: text/html\n\n"; print "name: ",$::user->name,' uid: ',$::user->{data}{uid}; print $::ht->output; sub defaultTmplData { my $sql="SELECT mid,tinythumb FROM movies ORDER BY rank DESC limit + 0,5"; my $pn=$::dbh->prepare($sql); $pn->execute; $pn->bind_columns(\my($mid,$thumb)); my @thumbs; while($pn->fetch) { push @thumbs,{thumb_id=>$mid,thumb_url=>$thumb}; } #$::ht->param(thumb_loop=>[@thumbs]); $::ht->param(thumb_loop=>[{}]); }
Note, if you comment out the second to the last line $::ht->param(thumb_loop=>[{}]); You no longer get two warnings.

And here is the template it uses:
<html> <head> <style> @import "css/default.css"; <tmpl_loop name='css_import'> @import "css/<tmpl_var name='css_file'>"; </tmpl_loop> </style> <script> </script> </head> <body> <div id='menu'> <br><br><br><br> <br> <h1>Movies</h1> <ul> <li> <a href='?o=movie&p=top10'>Top 10</a> < +/li> <li> <a href='?o=movie&p=browse'>Browse</a> </li +> <li> <a href='?o=movie&p=random1'>Random</a> </l +i> <li> <a href='?o=movie&p=submit'>Submit</a> </li +> <li> <a href='?o=movie&p=search'>Search</a> </li +> </ul> <h1>News</h1> <ul> <li> <a href='?o=news'>News</a> +</li> <li> <a href='?o=add_news'>Add News</a> </li> </ul> <h1>Movie Editing</h1> <ul> <li> <a href='?o=me'>Front Page</a> + </li> <li> <a href='?o=me&p=newest'>Newest Nodes</a> + </li> <li> <a href='?o=me&p=cat&c=question'>Questions</a> + </li> <li> <a href='?o=me&p=cat&c=theory'>Theories</a> + </li> </ul> </div> <div id='title'> <h1>Title!</h1> </div> <div id='main'> <tmpl_var name='main_content'> </div> <div id='thumbs'> <h1>Thumbs</h1> <ul> <tmpl_loop name='thumb_loop'> <li><a href='?o=movie&p=view&id=<tmpl_var name="thumb_ +id">'><img src='<tmpl_var name="thumb_url">'></a></li> </tmpl_loop> </ul> </div> </body> </html>
Help..

In reply to HTML::Template, apache, two warnings by BUU

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.