iRemix94 has asked for the wisdom of the Perl Monks concerning the following question:
I am a trainee and have to write a HTML-generating script. I use HTML::Template for that. Right now, I am currently stuck and get the following error: Attempt to set nonexistent parameter 'loop_name' - this parameter name doesn't match any decleration in the template file. What I want to get into the template is something like this: CUSTOMER -> DOMAIN -> MACHINE -> SCHEDULED_EXPORT_TIMES now, every machine can have more than one export a day. So right now I try to iterate through all the values and am stuck at the SCHEDULED_EXPORT_TIMES. Here's the Script:
for my $customer (keys %$bi) { for my $domain (keys %{$bi->{$customer}}) { my %customer_domain_data; $customer_domain_data{CUSTOMER}=$customer; $customer_domain_data{DOMAIN}=$domain; print "$customer\n\t$domain\n"; for my $host (keys %{$bi->{$customer}->{$domain}}) { my $schedule = $bi->{$customer}->{$domain}->{$host}->{BACK +UPCFG}->{EXPORT_SCHEDULE_1}->{VALUE}; if (defined $schedule) { my @schedule_rows_loop =(); my @schedule=split(/,/, $schedule); for my $dif_schedule(@schedule) { my %schedule_rows_data; print "\t\t$dif_schedule\n"; $schedule_rows_data{SCHEDULE}=$dif_schedule; print "\t\t $schedule_rows_data{SCHEDULE}\n"; push (@schedule_rows_loop, \%schedule_rows_data); print Dumper(@schedule_rows_loop); $template->param(SCHEDULE_ROWS => \@schedule_rows_ +loop); } } push (@customer_domain_loop, \%customer_domain_data); $template->param(CUSTOMER_DOMAIN => \@customer_domain_loop +); } } }
And here is the used part in the Template:
<TMPL_LOOP NAME=CUSTOMER_DOMAIN> <tr> <td><TMPL_VAR NAME=CUSTOMER></td> <td><TMPL_VAR NAME=DOMAIN></td> <td> <table style="Width:100%"> <TMPL_LOOP NAME=SCHEDULE_ROWS> <tr> <td><TMPL_VAR NAME=SCHEDULE></td> </tr> </TMPL_LOOP> </table> </td> </tr> </TMPL_LOOP>
I just recently started to learn PERL and I am not that fit in it, so bare with me and my probably silly mistakes!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Template frustrated...
by tangent (Parson) on Jul 14, 2015 at 13:54 UTC | |
by iRemix94 (Sexton) on Jul 15, 2015 at 06:11 UTC | |
|
Re: HTML::Template frustrated...
by 1nickt (Canon) on Jul 14, 2015 at 13:29 UTC | |
by iRemix94 (Sexton) on Jul 14, 2015 at 13:35 UTC | |
by 1nickt (Canon) on Jul 14, 2015 at 14:08 UTC |