I can't figure out what I am doing wrong and so I turn to the monks....

I have a function (see below) that prepares and calls the results of a SQL SELECT for an HTML::Template TMPL_LOOP. The function passes the SQL statement to another function which does the database lookup and returns an array of hashes (each column = 1 hash key). The function below refines the data a bit more (resolves table references into something more understandable for humans) and passes the refined array of hash references onto HTML::Template.

For some strange reason the assignment of the array to the appropriate TMPL_LOOP gives me a 500 error (notated in the code as the line that give me angst). If I comment out this line the page is served without issue (albeit without the results of the SELECT statement).

I put in some diagnostics to make sure there weren't any problems with the array of hash refs just before the assignment and all looked fine. I successfully use TMPL_LOOP in several places throughout my entire script and the syntax is the same everywhere, but this is the only place it seems to be broken.

NOTES: GetListFromDB does the SQL calls and returns the original array of hashes and GetItemFromDB resolves coded entries to strings. If it would help to see them let me know and I will post them. Thank you

I await absolution....

sub ShowLibLog { my $SQL = 'SELECT LibID, UID, ActionID, TXDate, Time, DocName, FromHos +t FROM LibrarianLog'; + my @log = GetListFromDB($SQL); my $item; my @liblog; foreach $item (@log) { # GetListFromDB will store the results of the sql statement in an arra +y of hash # references. Our first step is to create an array of hashes to be pa +ssed to # HTML::Template for display based on the results of the SQL statement +. *PHEW* my %entry = (LibID=>%$item->{'LibID'}, UID=>GetItemFromDB('RealName','UID', %$item->{'UID'},'User'), ActionID=>GetItemFromDB('ActionName','ActionID', %$item->{'ActionID'},'Action'), TXDate=>%$item->{'TXDate'}, Time=>%$item->{'Time'}, DocName=>%$item->{'DocName'}, FromHost=>%$item->{'FromHost'}); push (@liblog, \%entry); } $viewliblog_page->param(liblog=>\@liblog); #This is the line giving me + angst!!! print "Content-type: text/html\n\n", $viewliblog_page->output; }

In reply to Trouble with TMPL_LOOP assignment by spork

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.