I've got another question about the HTML::Template module. I want to repeat a certain block of HTML-Tags according to a given number. In my case: I want to create a table with X columns. Right now I don't know how to make that simple step possible. I tried a TMPL_LOOP, but in my understanding it needs an array ref, filled with hash refs. So I tried to make a hash array with X entries (X is the amount of columns) and tried to repeat the (td) block for every entry in it. But that doesn't work at all.. Is there an easier way, or do I have to do it like that and just make a mistake?Because I get the following error message:

HTML::Template->output() : fatal error in loop output : HTML::Template + : Attempt to set nonexistent parameter 'schedule_columns' - this par +ameter name doesn't match any declarations in the template file : (die_on_bad_par +ams => 1) at D:/Programme/Perl814/lib/HTML/Template.pm line 3304 at martin3.pl line 121

Here's the TMPL-part:

<TMPL_LOOP NAME=DATA_STRUCTURE> <TMPL_IF NAME=BGCOLOR_CUSTOMER> <tr> <TMPL_ELSE> <tr bgcolor="white"> </TMPL_IF> <th><TMPL_VAR NAME=CUSTOMER></th> <th><TMPL_VAR NAME=DOMAIN></th> <td> <TMPL_IF NAME=EXPORT_VALUE> <table style="Width:100%"> <TMPL_LOOP NAME=SCHEDULE_ROWS> <tr> <TMPL_LOOP NAME=SCHEDULE_COLUMNS> <td><b><TMPL_VAR NAME=SCHEDULE></b></t +d> </TMPL_LOOP> </tr> </TMPL_LOOP> </table> </TMPL_IF> </td> <td> <TMPL_IF NAME=IMPORT_VALUE> <table style="Width:100%"> <TMPL_LOOP NAME=SCHEDULE_ROWS> <tr> <TMPL_LOOP NAME=SCHEDULE_COLUMNS> <td><b><TMPL_VAR NAME=SCHEDULE></b></t +d> </TMPL_LOOP> </tr> </TMPL_LOOP> </table> </td> </TMPL_IF> </tr> </TMPL_LOOP>

Here's the PERL code:

for my $domain (keys %{$bi->{$customer}}) { my %data_structure; my @schedule_rows_loop; my @schedule_columns_loop; $data_structure{CUSTOMER}=$customer; $data_structure{DOMAIN}=$domain; for my $host (keys %{$bi->{$customer}->{$domain}}) { my $schedule = $bi->{$customer}->{$domain}->{$host}->{BACK +UPCFG}->{EXPORT_SCHEDULE_1}->{VALUE}; if (defined $schedule) +## Da nicht alle Kunden / Domainen zurzeit eine EXPORT_SCHEDULE haben { my $import_value=$bi->{$customer}->{$domain}->{$host}- +>{BACKUPCFG}->{IMPORT_ACTIVE_1}->{VALUE}; my $export_value=$bi->{$customer}->{$domain}->{$host}- +>{BACKUPCFG}->{EXPORT_ACTIVE_1}->{VALUE}; my $scheduled_export_days =convert_seconds_days(($bi-> +{$customer}->{$domain}->{$host}->{BACKUPCFG}->{EXPORT_BACKUP_LIFETIME +_SEC_1}->{VALUE})); $data_structure{IMPORT_VALUE}=$import_value; $data_structure{EXPORT_VALUE}=$export_value; my @schedule=split(/,/, $schedule); for my $dif_schedule(@schedule) { my %schedule_rows_data; $schedule_rows_data{SCHEDULE}=$dif_schedule; push (@schedule_rows_loop, \%schedule_rows_data); } for(my $i=0;$i<=$scheduled_export_days;$i++) { my %schedule_columns_data; $schedule_columns_data{SCHEDULE_COLUMNS_COUNT}=1; push (@schedule_columns_loop, \%schedule_columns_d +ata); } } } $data_structure{BGCOLOR_CUSTOMER}=$tr_bgcolor; $data_structure{SCHEDULE_ROWS} = \@schedule_rows_loop; $data_structure{SCHEDULE_COLUMNS} =\@schedule_columns_loop; push (@data_structure_loop, \%data_structure); print Dumper(\@data_structure_loop)."\n"; } } $template->param(DATA_STRUCTURE => \@data_structure_loop);

In reply to HTML::Template question by iRemix94

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.