Re: Handling array reference

Rajesh Saha <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CADoJNqCrp8ZdLBVcyZETXjvFgd=m8H-oNd160+aO1xjDHJwYyQ@mail.gmail.com>
Hi All,
Got the solution ..

[% FOREACH key IN hash.keys %]
[% key %] [% ":" %][% hash.$key.0 %][% hash.$key.1 %]
[% END %]

Regards,
Rajesh



On Tue, Apr 10, 2012 at 11:56 AM, Rajesh Saha <[email protected]>wrote:

> Hi
>
> *I have a perl script like this:*
>
> #!/usr/bin/perl
> use Template ;
> $tt = Template->new();
> $file = "test.tt" ;
> %hash = (
>              'a' => [1,2],
>               'b' => [3,4],
>                ) ;
> $vars = {
>               hash => \%hash
>              } ;
> $tt->process($file,$vars) ;
>
>
> *The template file (test.tt) is like this :*
>
> [% FOREACH key IN hash.keys %]
> [% key %] [% ":" %][% key.0 %][% key.1 %]
> [% END %]
>
> *My intension is to get an output like this :*
>
> a : 1 2
> b : 3 4
>
> But, I not getting. Actually, I don't know how to handle the reference in
> template . Can anybody please help ?
>
>
> Thanks n regards
> Rajesh Saha
>
>

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.