I'm just beginning to learn how to use the Dancer2 framework and am having problems displaying the results of a $sth->fetchall_hashref DBI querry.

I started with the example code from the "Our first route handler" section in the Dancer2::Tutorial documentation and adjusted it slightly to match my requirements.

Route Handler:

get '/partners' => sub { my $dbh = get_db_connection(); my $sth = $dbh->prepare("SELECT TPID, TPCOMPNAME, TPTYPE FROM TRADINGPARTNERPROFILE ORDER BY TPID LIMIT 2"); $sth->execute; my $partners = $sth->fetchall_hashref('TPID'); my $dump = Dumper($partners); $dbh->disconnect; template 'show_partners.tt', { 'dumper' => $dump, 'partners' => $partners, }; };\

Template:

<div> <pre><% dumper %></pre> <% FOREACH partner IN partners.keys %> Partner: <% partners.$partner.TPCOMPNAME %> <% partners.$partner.T +PTYPE %><br> <% END %> </div>

Resulting html output

<div> <pre>$VAR1 = { 'AB DISTRIBUTING INC.' => { 'TPTYPE' => '1', 'TPID' => 'AB DISTRIBUTING INC.' +, 'TPCOMPNAME' => 'AB Distributing + Inc.' }, 'A.T. CROSS ' => { 'TPTYPE' => '1', 'TPID' => 'A.T. CROSS ', 'TPCOMPNAME' => 'A.T. Cross ' } }; </pre> Partner: <br> </div>

What am I doing wrong which is preventing the desired output in the loop?

Edit:
One factor which may be important is that I'm testing this on Win7 perl v5.16.1 and will be deploying the app on a CentOS system which will probably be running perl v5.18.2


In reply to Dancer2 - How to loop over a ref to a HoH by fishmonger

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.