Hello
I'm just at the beginning of using TT from perl.
I have the following (probably simple) problem - but I don't see the solution:
---------------
#!perl
use Template;
my @array;
push @array,'entry1';
push @array,'entry2';
push @array,'entry3';
push @array,'entry4';
# Test1
print "\nTEST1:\n";
my $retstr1;
my $tt1 = Template->new({ VARIABLES => { version => 3.14, release =>'Sahara',
},});
my $vars = { serial_no => 271828};
my $templ1 = "This is version [% version %] ([% release %]). - Serial number:
[% serial_no %]";
$tt1->process(\$templ1, $vars,\$retstr1);
print $retstr1."\n";
#----------------------
#Test2
print "\nTEST2:\n";
my $retstr2;
my $templ2 ="[% FOREACH item IN arr %][% item %][% END %]";
my $tt2 = Template->new()|| die "ERROR!!\n";
$tt2->process(\$templ2, {arr => [EMAIL PROTECTED], \$retstr2)|| die
"ERROR!!".$tt2->error()."\n";
print $retstr2."\n";
#----------------------
#Test3
print "\nTEST3:\n";
my %param;
my $retstr3;
my $templ3 ="[% arr.join(\"\n\") %]";
my $tt3 = Template->new()|| die "ERROR!!\n";
$param{'arr'[EMAIL PROTECTED];
$tt3->process(\$templ3, \%param, \$retstr3)|| die "ERROR!!".$tt3->error()."\n";
print $retstr3."\n";
exit;
---------------
The first Test of the script is a slightly modified example from the TT-docu. -
the second and third test are my trials to process array ...
Running this script, I got the following output (while debugging in Komodo):
---------------
TEST1:
Use of uninitialized value in concatenation (.) or string at SCALAR(0x200dff8)
line 1.
Use of uninitialized value in concatenation (.) or string at SCALAR(0x200dff8)
line 1.
This is version (). - Serial number: 271828
EST2:
template error - line 1: unexpected END directive
*** SCRIPT DIES HERE!!!!
TEST3:
Use of uninitialized value in concatenation (.) or string at SCALAR(0x200e10c)
line 1.
template error - (no information)
*** SCRIPT DIES HERE! (AFTER DEACTIVATING TEST2)
---------------
So what's wrong here?
Thanks
Johannes
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates