-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Pronichev Alexander wrote:
> On Mon, 21 May 2007 20:05:58 +0400
> "Sergey Martynoff" <[EMAIL PROTECTED]> wrote:
>
>> SM >
>> SM > > Hi everybody. I think I've found a bug in Template/Base.pm
>> SM > > constructor (TT version 2.15). You have to call "map" (line
>> SM > > 68) in list context explicitly (from perldoc -f map : "In
>> SM > > scalar context, returns the total number of elements so
>> SM > > generated"). Patch in attach.
>> SM >
>> SM > Sorry, compatriot, but that's all right with Template::Base. The "map"
>> there
>> SM > is already in the list context, because is placed inside hash braces.
>> And,
>> SM > anyhow, the whole Template Toolkit won't work, if it would be in scalar
>> SM > context ;)
>
> Did you look in Template::Base code? This bug is not critical because
> BASEARGS array is empty for all descendants and _init method is called after
> constructing $self;
> Try this example (it's a little modified part of Template::Base):
Moving the map call to the end of that list, after the _ERROR and DEBUG
entries, would also fix it. The problem is that the map call is
accepting the list that comes after it as parameters, it's the same as
this:
{ map { ($_ => shift @args) } ( @$argnames, '_ERROR', '', 'DEBUG', 0 ) }
But if you move the map to the end, or put parentheses around it, perl
no longer includes the other values as parameters to map.
In fact, the only problem with the code as it is is that you get undef
instead of '' for _ERROR and undef instead of 0 for DEBUG, and then you
get the extra '' and 0 keys that also have undef values. It'll probably
cause warnings, but nothing more...
But it's still wrong, and should be fixed. :-)
> ========cut========
> #!/usr/local/bin/perl -w
> use strict;
> use Data::Dumper;
> my $argnames = [];
> my @args = ();
> my $hash = {
> map { ($_ => shift @args) } @$argnames,
> _ERROR => '',
> DEBUG => 0,
> };
> warn Dumper($hash);
> ========/cut========
> with and without braces around map.
>> SM >
>> SM >
>> SM > --
>> SM > Sergey Martynoff
>> SM >
>
>
- --
C. Chad Wallace, B.Sc.
The Lodging Company
http://www.skihills.com/
OpenPGP Public Key ID: 0x262208A0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGUeZ3KeSNHCYiCKARAvCaAJ0fbsCKIHDNqq9WO0uhF332xK39LQCgj2il
BE6HPeXWUnONB1CVo/30QLk=
=P3DO
-----END PGP SIGNATURE-----
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates