in reply to Re^3: How do I cope with nested TMPL_VAR in HTML::Template::Pro?
in thread How do I cope with nested TMPL_VAR in HTML::Template::Pro?

Consider the case you use DBI to fetch the result of show tables,

whose keys are in the format Tables_in_db_name, there's no way to reduce it into a fixed key,

as it changes according to the database name .

Is there a better option than copy the whole hash into another one with fixed keys(as obviously this is causing duplicate data)?

Replies are listed 'Best First'.
Re^5: How do I cope with nested TMPL_VAR in HTML::Template::Pro?
by moritz (Cardinal) on Aug 03, 2011 at 15:07 UTC

    show tables just returns one column. You can just do something like

    my @loop; while (my @cols = $sth->fetchrow_array) { push @loop, { table_name => $cols[0] }; } $tmp->param(loop => \@loop);

    There you go, fixed name (table_name) to pass to your template.

    P.S. if you had provided enough context from the very beginning, it would have been much easier to help you straight away.

      I can't,cause I'm using another encapsulated DB interface which essentially just return the result of $sth->fetchall_array.

      Of course I can blend it again, but it's also bringing overhead,right?

      Is there a way to do the real nested TMPL_VAR thing?