> I'm having difficulty working out how to put an undef into
> a hash. I expected the following to work, leaving the undef
> value for the key "blah".
>
> $ cat test.tt2
> [% USE Dumper;
> hash = {};
> hash.blah = something_not_defined;
> Dumper.dump(hash);
> %]
>
In TT there is practically no undef value. Look at the
Template::Stash module's 'get' and 'undefined' methods. When you
call $stash->get( 'something_not_defined' ), the 'get' methods
sees that there is no variable by that name and returns result of
$self->undefined call. By default, 'undefined' method returns an
empty string.
This behavior is good for the sake of simplicity of TT language.
But if you want to change this, just subclass Template::Stash and
change the only 'undefined' sub. Or you may try to redefine the
'undefined' sub with some black magic like this:
*{ Template::Stash::undefined } = sub { undef };
# this line should be executed AFTER Template->new call
--
Sergey Martynoff
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates