for my $customer (keys %$bi) { for my $domain (keys %{$bi->{$customer}}) { my %customer_domain_data; my @schedule_rows_loop; for my $host (keys %{$bi->{$customer}->{$domain}}) { if (defined $schedule) { for my $dif_schedule(@schedule) { push (@schedule_rows_loop, \%schedule_rows_data); } } } $customer_domain_data{SCHEDULE_ROWS} = \@schedule_rows_loop; push (@customer_domain_loop, \%customer_domain_data); } } $template->param(CUSTOMER_DOMAIN => \@customer_domain_loop);