I have a template in which i populate router and interfaces (<TMPL_VAR NAME>)
In the tmpl i want to generate a link with the above variables as parameters <a href = "display_graph.cgi?router=<TMPL_VAR NAME="router">&interface=<TMPL_VAR NAME="interface"></a>
Above does not work how do i get the variables passed as params to another script
See full code below

Database
site router interface dlh 138.188.193.233 FastEthernet0/0 dlh 138.188.193.233 Serial0/0

script that populates the tmpl
use strict; use warnings; use DBI; use HTML::Template; use Log::Log4perl; Log::Log4perl->init("/home/ndb/config/dlh_ndb_log.conf"); my $log = Log::Log4perl->get_logger(); my $template = new HTML::Template(filename=>"home1.tmpl"); my $dbh = DBI->connect('dbi:mysql:ndb','esm','esm') || die "Cannot con +nect"; #print "\n Connected....."; my @loop_data; my @sites; my @routers; my $query = "select distinct site_name from sites order by site_name"; my $sth = $dbh->prepare($query); $sth->execute; my $query_router = "select distinct router from sites where site_name += ?"; my $sth_router = $dbh->prepare($query_router); my $query_interface = "select interface from sites where site_name = ? + and router = ?"; my $sth_interface = $dbh->prepare($query_interface); while(@sites = $sth->fetchrow_array) { my @r_loop_data; $sth_router->bind_param(1,$sites[0]); $sth_router->execute; while(@routers = $sth_router->fetchrow_array) { my @interfaces; $sth_interface->bind_param(1,$sites[0]); $sth_interface->bind_param(2,$routers[0]); $sth_interface->execute; while(my @arr = $sth_interface->fetchrow_array) { my %interface_row = ( interface => $arr[0] ); push(@interfaces, \%interface_row); } my %row; %row = ( router => $routers[0] , interfaces_loop => \@interfaces ); push(@r_loop_data,\%row); } my %site_row = ( site => $sites[0], routers_loop => \@r_loop_data ); push(@loop_data, \%site_row); } $template->param(caption => "ST Sites"); $template->param(sites_loop => \@loop_data); print "Content-Type: text/html\n\n"; print $template->output; $dbh->disconnect or $log->logwarn("Cannot disconnect from the database +: $DBI::errstr"); exit 0;
<html> <body LINK="blue" ALINK="green" VLINK="#4169e1"> <table border="0" CELLPADDING="20" CELLSPACING="20" WIDTH="1000"> <tr> <td align = "center"><TMPL_INCLUDE NAME = "/var/www/cgi-bin/nd +b_header.tmpl"></td> </tr> <tr> <td align = "center"> <table border="1" CELLPADDING="0" CELLSPACING="0" WIDTH="1 +00%"> <caption > <b><TMPL_VAR NAME = "caption"></b> </h2> <TMPL_LOOP NAME="sites_loop"> <tr bgcolor = "cornflowerblue" text = "white"> <th colspan = "2" align = "left"><font color="white"> +<TMPL_VAR NAME = "site"></font></th> </tr> <TMPL_LOOP NAME="routers_loop"> <tr bgcolor = "powderblue"> <td align = "left"><font color = "navy"><b><TMPL_V +AR NAME="router"></b></font></td> <td align = "left"><TMPL_LOOP NAME = "interfaces_loop" +><a href = "display_graph.cgi?router=pdel246&interface=FastEthernet0/ +0"><TMPL_VAR NAME="interface"></a> | </TMPL_LOOP></td> </tr> </TMPL_LOOP> </TMPL_LOOP> </table> </td> </tr> <tr> <td align = "center"><TMPL_INCLUDE NAME = "/var/www/cgi-bin/nd +b_footer.tmpl"></td> </tr> </table> </body> </html>

In the above tmpl i have hard coded the call to display_cgi? how do i get the links to generate based on tmpl population.
Thanks,
chimni
UPDATE Problem solved by making the template variabls global while creating HTML::Template object

In reply to HTML::Template : generation of links by chimni

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.