http://qs321.pair.com?node_id=1073765


in reply to Changing data structure with HTML::Template

Greetings jms53,

I think you'll need to change your data structure. HTML::Template expects to iterate through hashrefs in an array rather than arrayrefs.

$account->{transactions} = [ map { { line => $_ } } @transactions ]; push @transactions, { date => $date, type => $type, amount => $amount, balance => $new_balance };

Replies are listed 'Best First'.
Re^2: Changing data structure with HTML::Template
by jms53 (Monk) on Feb 07, 2014 at 11:51 UTC
    Thank you gryphon,

    I updated my code as you showed, and the page now loads. However, the html sent to the browser doesn't contain any data for the table.

    <table border="1"> <tbody><tr> <td></td><td>Date</td><td>Type</td><td>Amount</td><td>Balance</ +td> </tr> <tr><td>Transaction:</td> </tr> </tbody></table>

    What I'm supposed to be seeing is more something along the lines of :
     <tr><td>Transaction</td><td>2014-02-06</td><td>credit</td><td>400</td><td>1400</td></tr>

    I have debugged the data to confirm it exists (my first project I was deleting my data on the first run, and then all subsequent runs yielded 0 results), and I'm not getting any complaints from the server. If you have any ideas, they are most welcome :)

    J -