html template and tables



Hi all
I'm trying to do the following:
Print out the table from an array using HTML teplates.

I'm not sure of the sintax of how to get this table to display, I dont like
posting code here, but I'm kinda stuck and I dont know if I am going in the
right direction to do what I want to do.

my main problem is with this area of the code, and what to supply to
it................ if anyone has any good links please let me know.

# set up my table, and print it out
my $template = q{
<TABLE border=1><TMPL_LOOP name="table_data">
<TR><TMPL_LOOP name="date">
<TD><TMPL_VAR name="time"></TD>
</TMPL_LOOP></TR>
</TMPL_LOOP></TABLE>
};
#take it from the table and put pump it out on to the web
$template = HTML::Template->new(scalarref => \$template, option =>'value');
$template->param(table_data => \@table_data);


Thanks in advance






code is below:


_________________________________________________________________________________________
#!/usr/bin/perl

use strict;
use warnings;

my $data_file = 'myfile/var/log/my.log';
print "$data_file \n";

# Open the file for reading.
open (DATA, "$data_file") or die "can't open $data_file $!";
my @array_of_data = <DATA>;

print "this is the file: \n";
#print @array_of_data;
print "\n";


#Variable dlecrations
my $line;
my $testIf;
my @date;
my @time;
my @IVM;
my @ID;





foreach my $line (@array_of_data)
{
# Start an if statement, the condition of which is
# "If this particular line contains the word dangerous."

######## chomping
#print "\n in foreach loop \n";
chomp($line);



if ( ($line =~ /TestString/i) && ($line =~ /TestString2/i) )
{

######Changing this to take this as an array
(@date, @time, @IVM, @ID) = split (' ', $line);

} # End the if condition here.

} # End the foreach loop here.

close (DATA);
###########################close the file



############################ template section
use HTML::Template;
# set up my table, and print it out
my $template = q{
<TABLE border=1><TMPL_LOOP name="table_data">
<TR><TMPL_LOOP name="date">
<TD><TMPL_VAR name="time"></TD>
</TMPL_LOOP></TR>
</TMPL_LOOP></TABLE>
};
#take it from the table and put pump it out on to the web
$template = HTML::Template->new(scalarref => \$template, option =>'value');
$template->param(table_data => \@table_data);

##print out html
print "Content-Type: text/html\n\n", $template->output;


Relevant Pages

  • Re: Listing objects
    ... When Template is instantiated, it instantiates Control, which, in turn, instantiates Data. ... Another way would be to have a global array and save all objects there by reference. ...
    (comp.lang.php)
  • Re: Question About temlates.
    ... >will act like a dynamic array. ... You're describing the right approach to creating a template from a ... a dynamic array generally means that there's at least one ... many elements in the constructor. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: nested conditional that can identify parent page?
    ... and specify the files in the array including ... try to make as little php and html mix as possible, have a template ...
    (alt.php)
  • Re: Locating an element within an array
    ... the array and check for certain values. ... SLP and return the last 3 integers. ... With the foreach loop this becomes: ... The problem with this line is you are using a numeric comparison ...
    (perl.beginners)
  • Re: Question About temlates.
    ... Leor Zolman wrote: ... but what I want to do is create a template class that ... >>will act like a dynamic array. ... > many elements in the constructor. ...
    (alt.comp.lang.learn.c-cpp)