http://qs321.pair.com?node_id=133396


in reply to Q / A and HTML::Template techniques...

Thanks Maverick, it is becoming more clear to me now ;). To prove the point, here's an excerpt from an app I'm now building:

File: main.cgi
#!/usr/local/bin/perl -w use strict; use HTML::Template; ################################### ## includes ################################### use XCGI; require "config.pl"; ################################### ## MAIN ################################### my $cgi = new XCGI; # my version of CGI (with a few subs added/redefin +ed). print $cgi->header(); my $template = new HTML::Template(filename => "$CONFIG::template_root/ +main.tmpl", die_on_bad_params => 0); $template->param( select_box_datasource => $cgi->select_list(-name=>'s_dns', -values=>[keys(%CONFIG::ds_info)], -labels=>{sh=>\%CONFIG::ds_info, so +urce_key=>'info'}, -default=>['webdb'], -size=>1), ); print $template->output();

File: templates/main.tmpl
<html> <title>Automation Tool</title> <body> <form> <table border=1 > <tr> <td> Select Datasource: <TMPL_VAR NAME="select_box_datasource"> <br> </td> </table> </form> </body> </html>
Note that select_box_datasource variable will hold a piece of custom built html similar to this:
<SELECT NAME="s_dns" SIZE=1> <OPTION VALUE="foo">Production <OPTION SELECTED VALUE="foobar">Development <OPTION VALUE="bar">Development 1 </SELECT>

the select_list() subroutine is implemented (overwritten) inside XCGI module which serves as my (custom) extension to standard CGI. Although, CGI has a similar subroutine, it didn't fit the needs of my application (as seen from the code...).


"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith