W
webvoip
EHLO,
I'm toying around with Text::Template and have a question for anyone
who may know this out there...
I have a template that has the following code:
<table>
<tr><td colspan="100%">Edwin's Test Table</td></tr>
{
my $sth = $dbh->prepare("select * from t");
$sth->execute;
while (my $h = $sth->fetchrow_hashref)
{
print " <tr><td>$h->{id}</td><td>$h->{stuff}</td></tr>\n";
}
}
</table>
And my calling application exports the $dbh handle via the package
option using fill_in:
$PackageName::dbh =
DBI->connect("DBI:mysql:database=test;host=test1", "username",
"password") || die($!);;
my $t = Text::Template->new(TYPE => 'FILE', SOURCE =>
'../templ/t.tmpl') or die ($Text::Template::Error);
my $text = $t->fill_in(PACKAGE => 'PackageName');
print $text;
It works... somewhat... The problem i am having is that the print order
is wrong. Is there some pre-processing or other simple option i am
missing?
Here's what prints out (notice the table rows print first):
<tr><td>1</td><td>one</td></tr>
<tr><td>2</td><td>two</td></tr>
<tr><td>3</td><td>three</td></tr>
<tr><td>4</td><td>four</td></tr>
<tr><td>5</td><td>five</td></tr>
<html>
<body bgcolor="#ffffff" text="#000000">
<table>
<tr><td colspan="100%">Edwin's Test Table</td></tr>
<!-- table rows should be here -->
</table>
</body>
</html>
Thanks and apologies if i posted this to the wrong newsgroup.
-Edwin
I'm toying around with Text::Template and have a question for anyone
who may know this out there...
I have a template that has the following code:
<table>
<tr><td colspan="100%">Edwin's Test Table</td></tr>
{
my $sth = $dbh->prepare("select * from t");
$sth->execute;
while (my $h = $sth->fetchrow_hashref)
{
print " <tr><td>$h->{id}</td><td>$h->{stuff}</td></tr>\n";
}
}
</table>
And my calling application exports the $dbh handle via the package
option using fill_in:
$PackageName::dbh =
DBI->connect("DBI:mysql:database=test;host=test1", "username",
"password") || die($!);;
my $t = Text::Template->new(TYPE => 'FILE', SOURCE =>
'../templ/t.tmpl') or die ($Text::Template::Error);
my $text = $t->fill_in(PACKAGE => 'PackageName');
print $text;
It works... somewhat... The problem i am having is that the print order
is wrong. Is there some pre-processing or other simple option i am
missing?
Here's what prints out (notice the table rows print first):
<tr><td>1</td><td>one</td></tr>
<tr><td>2</td><td>two</td></tr>
<tr><td>3</td><td>three</td></tr>
<tr><td>4</td><td>four</td></tr>
<tr><td>5</td><td>five</td></tr>
<html>
<body bgcolor="#ffffff" text="#000000">
<table>
<tr><td colspan="100%">Edwin's Test Table</td></tr>
<!-- table rows should be here -->
</table>
</body>
</html>
Thanks and apologies if i posted this to the wrong newsgroup.
-Edwin