Hello all,

I think I've found a small bug in param().  It's not a killer for me, but
I thought I'd mention it.  Here's an example that triggers the behavior
I'm seeing (I'm using HTML::Template version 2.8, but I think 2.9 would
behave this way, too):

perl -MHTML::Template -wle'$o="<TMPL_VAR x>";$t=HTML::Template->new(scalarref=>\$o);$t->param(x=>\{});print $t->output()'
Can't call method "isa" on unblessed reference at /opt/perl/lib/site_perl/5.8.8/HTML/Template.pm line 2527.

Line 2527 looks like this:

 if (defined($value_type) and length($value_type) and ($value_type eq 'ARRAY' or ((ref($value) !~ /^(CODE)|(HASH)|(SCALAR)$/) and $value->isa('ARRAY')))) {

What's happening is that $value_type is "REF", so it's getting past all
the other checks and calling isa(), giving the error.

First off, I think /^(CODE)|(HASH)|(SCALAR)$/) should instead be
/^(CODE|HASH|SCALAR)$/).  But if I'm following the logic correctly,
I think it should be /^(CODE|GLOB|HASH|LVALUE|REF|SCALAR)$/).

So I think the fix is to change that line to the following:

 if (defined($value_type) and length($value_type) and ($value_type eq 'ARRAY' or (($value_type !~ /^(CODE|GLOB|HASH|LVALUE|REF|SCALAR)$/) and $value->isa('ARRAY')))) {

(Note that I also replaced ref($value) with $value_type.)

When I rerun the above one-liner with this change, the output is

REF(0x14b1d8)

which is consistent with what you currently get if you pass, say, a
hash reference, e.g.,

perl -MHTML::Template -wle'$o="<TMPL_VAR x>";$t=HTML::Template->new(scalarref=>\$o);$t->param(x=>{});print $t->output()'
HASH(0x124170)

I hope that all makes sense.  I have *not* run this through the
tests, though, so I don't know if that will show up flaws in my
understanding.

Thanks,

-- Brad