On Oct 5, 2005, at 2:46 AM, Francois Billard wrote:

Hi,
 
I have a key of a hastable with dot inside (ex : foo.bar) , how should display it in my web page ? if i use this :
[% myhash.foo.bar %]   it doesn t work because TT engine see the dot of foo.bar as a data structure separator.
how extract the value of my $myhash{"foo.bar"} with TT ??

Assign "foo.bar" to a variable, and use that variable to look it up, like [% myhash.$key %]

here is a complete file:

#!/usr/bin/perl -w

use strict;
use Template;
Template->new->process(\*DATA, {yo=>{"ya.ye"=>"yu"}}) || die Template->error;;
__DATA__
[%#unexpected token yo."ya.ye" %]
[% key = 'ya.ye' %]
[% yo.$key %]

iirc (and I might not), there was talk about using . for dereference in Perl 6. If that is the case, now would be a good time to stop using dot in your hash keys if you can avoid it.

mike


 
thanks in advance
Francois


--
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.6/111 - Release Date: 23/09/2005

Reply via email to