Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Template::Toolkit - How do i access alias-based results?

by Yaerox (Scribe)
on Jul 13, 2015 at 14:23 UTC ( #1134515=note: print w/replies, xml ) Need Help??


in reply to Re: Template::Toolkit - How do i access alias-based results?
in thread Template::Toolkit - How do i access alias-based results?

Dump seems to work fine ...

[% FOREACH user = query.execute() %] [% Dumper.dump( user ) %] <tr class="tbl_3_col_ia_tr1"> <td class="tbl_3_col_ia_td tbl_3_col_i +a_td_1 tbl_3_col_ia_text"> <span> [% user.vertragsnummer %] </span> </td> <td class="tbl_3_col_ia_td tbl_3_col_i +a_td_2 tbl_3_col_ia_text"> <span class="tbl_3_col_ia_span_mid +_l"> [% user.artikelnr %] </span> <span class="tbl_3_col_ia_span_mid +_r"> </span> </td> <td class="tbl_3_col_ia_td tbl_3_col_i +a_td_3 tbl_3_col_ia_text"> <span class=""> </span> </td> </tr> [% END %]

Output (dump works fine, my output still is empty):
$VAR1 = { 'DATUM' => '09-JUL-15', 'STATUS' => 'Eingelesen', 'NR' => '1 +1000530', 'NACHRICHT' => '528', 'aNR' => '8041094A' }; $VAR1 = { 'aNR +' => '8033010E', 'NR' => '11000527', 'STATUS' => 'Eingelesen', 'NACHR +ICHT' => '1559', 'DATUM' => '09-JUL-15' }; [...]

Well, if I do user.SOMESTUFF and SOMESTUFF in Uppercase it works ...


Update: okay, I'd like to try the same now by passing values to template. Would you be so kind and help me here too? So I know both ways to do this ...
print "Content-type: text/html\n\n"; my $oTT = Template->new({ INCLUDE_PATH => '../templates', EVAL_PERL => 1, ABSOLUTE => 1, }) || die "$Template::ERROR\n"; #DB - Connect my $hDB = DBI->connect( "dbi:Oracle:xx", "xx", "xx", { AutoCommit => 0 + } ); my $hStatement = $hDB->prepare("MYSQL"); $hStatement->execute( ); while ( ( $iVertragsnummer, $sArtikelNr, $sVertragsStatus, $sVertragsD +atum, $iMsgID ) = $hStatement->fetchrow_array() ){ push (@aRows, ( $iVertragsnummer, $sArtikelNr, $sVertragsStatus, $s +VertragsDatum, $iMsgID )); } $hStatement->finish; $hDB->disconnect; my $sData = { 'result' => \@aRows }; $oTT->process("../templates/mytemplate.html", $sData) || die $oTT->err +or(), "\n";
[% FOREACH line IN result %] [% Dumper.dump( line ) %] [% line.VERTRAGSNUMMER %] [% line.ARTIKELNR %] [% END %]
I get the following output of my dump:
$VAR1 = '11000530'; $VAR1 = '8041094A'; $VAR1 = 'Eingelesen'; [...]
my line.vars are empty again. I think I'm doing something wrong with references in perl?

Replies are listed 'Best First'.
Re^3: Template::Toolkit - How do i access alias-based results?
by Anonymous Monk on Jul 13, 2015 at 16:38 UTC
    I think I'm doing something wrong with references in perl?

    You're doing something wrong with @aRows alright - and the solution has already been given to you here

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1134515]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-11-21 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (294 votes). Check out past polls.

    Notices?