HTML::Template is still choking, giving the error...

HTML::Template->new() : Syntax error in <TMPL_*> tag at /XXX[here I'm
ommiting the path]XXXX/data/templates/student_info.tmpl : 13. at
/usr/local/lib/perl5/site_perl/5.005/HTML/Template.pm line 2243.

I now think the fault is in my Perl code which handles the %datahash
that is tied to a file. I'm new to this and this script is the most complicated
I've ever tried. Sorry to post so much code, but my blunders the the light
of day and some sound criticism. Many thanks in advance!


#!/usr/bin/perl -w
use strict;
use CGI;
        $CGI::DISABLE_UPLOADS = 1;
        $CGI::POST_MAX = 102_400; # 100 KB
use DB_File; # module for Berkeley DBM w/ DB_HASH file type
use Fcntl qw/ :DEFAULT :flock /; # to help with file handling
use HTML::Template;
# This script is called by a post from "student_info_viewer.html"
#       or a post from the HTML page generated by this script

# Array all the parameters we will use
my @info_prams = qw(
        student_info
        name_full                       enroll_type
        name_nick                       account_number
        name_last                       password
        date_birth                      student_email
        sex                                     mentor_email
        date_entered            suspended
        date_withdrawn          
);

# ID the student and change to student's directory
my $q = new CGI;
my $student_id = $q->param ( "student_id" );
chdir "/xxxxxxxxxxxxxxxx/data/students/$student_id/";
my $file_to_view = "student_info.db";

# Declare the 'working' datahash, then tie it to file
my %datahash;
my $db = tie %datahash, 'DB_File', $file_to_view, O_RDWR | O_CREAT, 0644
        or die "Can't initialize database: $!\n";
my $fd = $db->fd(); # get a file descriptor
open DATAFILE, "+<&=$fd" or die "Can't safely open file: $!\n";
flock ( DATAFILE, LOCK_EX )
        or die "Unable to acquire exclusive lock: $!. Aborting";
undef $db; # Avoid untie problems

# Update the hash with the posted parameters
foreach (@info_prams) {
chomp;
$datahash{$_} = $q->param ( $_ );
}
# Generate a page using the template and latest data
use constant TMPL_FILE => "/big/dom/xlibertylearning/data/templates/student_info.tmpl";
my $tmpl = new HTML::Template( filename => TMPL_FILE );
# Assign template parameters
foreach (@info_prams) {
$tmpl->param( $_ => $datahash{$_} );
}
print "Content-type: text/html\n\n",
$tmpl->output;
untie %datahash;
close DATAFILE;
exit;



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to