Gossamer Forum
Home : General : Perl Programming :

More Help

Quote Reply
More Help
Hi All:

Thanks for the help with installing text template. I thought it came along with perl. I guess I will have to spend more time at cpan. The piece of code below works fine. However, I have had some problems sending a single value like $value = "mike" using Text::Template. How is this done???



#!/usr/bin/perl
use warnings;
use DBI;
use Text::Template;
print"Content-type:text/html\n\n";
sub ConnectMain;
sub PrepareRead;
&PrepareRead();
#------------------------------------------------------------------------------
sub ConnectMain
{

my ( $dbc );
$dbc = DBI->connect("DBI:mysql:host=localhost;database=bargain","sdd","mahasa",{ PrintError => 0, RaiseError => 1 } );
return $dbc;
}#ok
#------------------------------------------------------------------------------
sub PrepareRead
{
my( $dbc,$dbs );
$dbc = ConnectMain();
$dbs = $dbc->prepare("SELECT * FROM first");
$dbs->execute();
$details = $dbs->fetchrow_hashref();

$template = new Text::Template (
TYPE => 'FILE',
SOURCE => 'king.html'
);

$filled = $template->fill_in(
HASH => [ $details ],
DELIMITERS => [ '[##', '##]' ]
);

print $filled;

}

Thanks...
Subject Author Views Date
Post More Help TheSafePick 2926 Apr 13, 2004, 3:21 PM