
prakashk
Deleted
Mar 30, 2000, 9:40 AM
Post #2 of 3
(613 views)
|
|
Re: Updating a site with new data
[In reply to]
|
Can't Post
|
|
You can use any of the several template-based methods to accomplish this. For example (using the module CGI::FastTemplate), you can create a template file (say, table.tpl) containing your HTML code, except the table: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> <HTML> ... <TABLE> $my_table_data </TABLE> ... ... </HTML> </pre><HR></BLOCKQUOTE> Notice the variable name '$my_table_data' above. Now in your script, do this: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> use CGI::FastTemplate; my $tpl = new CGI::FastTemplate("/path/to/templates"); $tpl->define(table => "table.tpl"); # get your table data and create HTML table rows out of them # and save it in the variable $latest_data $tpl->assign(my_table_data => $latest_data); $tpl->parse(NEW_HTML => "table"); $tpl->print; </pre><HR></BLOCKQUOTE> The above code prints your HTML in the template file replacing the variable $my_table_data with HTML rows of your latest data. This module is available at CPAN. The URL is <http://search.cpan.org/search?dist=CGI-FastTemplate> There are several modules on CPAN for template-based text (HTML or otherwise) generation. If you go to <http://search.cpan.org/search?mode=module&query=Template> you'll see a bunch of such modules. HTH, Prakash
|