CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Updating a site with new data



Mar 30, 2000, 7:13 AM

Post #1 of 3 (2572 views)
Updating a site with new data Can't Post


I wrote a cgi script in perl that accesses a database and pulls all info from a particular table that has been updated in the past 24 hours. While I can have this info returned from a form, I want have it on a scheduler to run every night and update an internal (i'm at work) site at a particular <table> in the site.

Not sure how I can populate the new data at a particular point in the html. I'm a bit of a rookie, so let me know if any more specifics are needed! An example would be great!


Mar 30, 2000, 9:40 AM

Post #2 of 3 (2572 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>



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");

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

There are several modules on CPAN for template-based text (HTML or otherwise) generation. If you go to <> you'll see a bunch of such modules.



Apr 3, 2000, 9:05 AM

Post #3 of 3 (2572 views)
Re: Updating a site with new data [In reply to] Can't Post

Thanks a million!! Hoping to find some time at work to implement!


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives