Handling array in template

Rajesh Saha <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CADoJNqCQ79kMToC1N3-CkH7QAKVXYr=z+B2P8=f0zTFfLZFVwQ@mail.gmail.com>
Hi

*I want my result to be like this :*

abc,def

*What I have done (in test.tt template file):*

[% FOREACH var IN vars %]
[%- var -%][%- "," -%]
[% END %]

*I have processed the above test.tt through perl file like this:*

#!/usr/bin/perl
use Template ;
$tt = Template->new();
$file = "test.tt" ;
$vars = {
            vars => ["abc" ,"def"]
            } ;
$tt->process($file,$vars) ;
*As expected, the output is:*
 abc,def,

How can I get the result the way I wanted (without the last comma) ? Help
pls.

Thanks n regards
Rajesh

_______________________________________________
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.