Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2023-05-30 00:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found