http://www.perlmonks.org?node_id=1113330

adriang has asked for the wisdom of the Perl Monks concerning the following question:

Hi All

I'm converting a CGI site to Dancer and I need to convert the FORM with popup_menu that have HASH as labels:

$cgi->start_form({-name=>'box_form',-target=>"_new"}), $cgi->font({-'size'=>2,-'color'=>"#2E2E2E",-'face'=>"arial"}),$cgi +->b(), $cgi->table({-width=>"600",-border=>"1", -cellpadding=>"5", -cells +pacing=>"2", -align=>"center",-bgcolor=>"#FFFFFF",-bordercolor=>"#6E6 +E6E"}, $cgi->Tr( $cgi->td({-align=>"center",-colspan=>"2"},$cgi->font({-'si +ze'=>4,-'color'=>"#2E2E2E",-'face'=>"arial"},"Query Done") ) ), $cgi->Tr({-align=>"right"}, $cgi->td( $cgi->popup_menu({-name=>"query",-values=>\@query_ +type_mainbox,-labels=>\%query_name_mainbox, -default=>"license"} ),"Q +uery Type"), $cgi->td( $cgi->popup_menu({-name=>"cust",-values=>\@cust_co +de_sorted,-labels=>\%cust_name} ),"Customer Name", $cgi->br(),$cgi->br(), $cgi->textfield({-size=>8,-name=>"free_cust"}), "C +ustomer Code") ), $cgi->Tr({-align=>"center"}, $cgi->td({-colspan=>"2"}, $cgi->submit(-name=>"Go")) ), ), $cgi->endform, ;


A good advice will be thankful how can I write the code into the template.tt file.
This is the route:

get '/' => sub { # Create customers list my $db = connect_db(); my $sth=$db->prepare("SELECT shortcut,nameheb FROM cust"); $sth->execute() or die "$DBI::errstr"; # Create customer HASH my %cust_name; my @cust_code; while(my ($shortcut,$name) = $sth->fetchrow_array()) { $cust_name{$shortcut}="$name"; } $sth->finish(); template 'index', { hash => \%cust_name }; };

Thanks in advance