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
|
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.