CC: | markdclements [...] yahoo.co.uk |
Subject: | Template toolkit FOREACH problem if UNIVERSAL::can is used |
Template toolkit fails on processing FOREACH without setting an error if
UNIVERSAL::can has been used. In effect, truncated output is returned.
I haven't found a workaround as yet.
use strict;
use warnings;
use Template;
use UNIVERSAL::can;
print "\$UNIVERSAL::can::VERSION: $UNIVERSAL::can::VERSION\n";
print "\$Template::VERSION: $Template::VERSION\n";
my $templateText = qq(
start
size = [% numbers.size %]
[% FOREACH number IN numbers %] [% number %]
[% END %]
end
);
my $params = {
numbers => [1,2,3]
};
my $template = Template->new( {DEBUG => 1 });
$template->process( \$templateText, $params ) or die $template->error;
output:
$UNIVERSAL::can::VERSION: 1.03
$Template::VERSION: 2.14
start
size = 3
comment out "use UNIVERSAL::can" and output is:
$UNIVERSAL::can::VERSION:
$Template::VERSION: 2.14
start
size = 3
1
2
3
end
perl is 5.8.7 on debian sarge. My windows box did not demonstrate this
problem until UNIVERSAL::can was upgraded from 1.00 to 1.03. I'm not
entirely sure whether this bug should be posted under UNIVERSAL::can or
Template toolkit. Apologies if I have made the wrong decision to post it
here first.
regards,
Mark