####### .pl file #!/usr/bin/perl use strict ; use warnings ; use CGI ; use Data::Dump 'pp'; use HTML::Template; use tmpl; my $data; ...more code goes here # Loading data from module -> tmpl.pm my $table_tmpl_loaded = one_table( $data ); # Loading data from module -> tmpl.pm my $main_out_tmpl = main( $data, $table_tmpl_loaded ); ...more code goes here ##### .pm file tmpl.pm sub main { my( $data, $table_data ) = @_; # Load Main Template my main_tmpl = HTML::Template->new(filename => 'main.tmpl', die_on_bad_params => 0,); my $text = $page->{more}->{menu}->{options} || []; my $account = $page->{more}->{account} || []; my $hidden = $page->{more}->{hidden} || []; $main_tmpl->param( TITLE => 'PROTOTYPE', TABLE => $table_data, TEXT => $text, ACC => $account, HIDD => $hidden, ); my $main_tmpl_loaded = $main_tmpl->output; return $main_tmpl_loaded; } sub one_table { my( $page_data ) = @_; # Load new template to add to main template later my $one_tmpl = HTML::Template->new(filename => 'templates/one_table.tmpl', die_on_bad_params => 0,); # Load data into the summary_table.tmpl $one_tmpl->param( ONE => $page->{more}->{one_name} || [], ONE_B => $page->{more}->{row} || [], OTHERS => $page->{more}->{bulid}->{row} || [], TOTAL => $page->{more}->{left_row}->{right}->{total} || '', ....many params here ); my $one_tmpl_loaded = $one_tmpl->output(); return $one_tmpl_loaded; } 1 ;