On 19 Jun 2008, at 14:15, Sharad Pratap wrote:

> I am new user to ttk, I need to process aa mail text for different  
> people in a loop
> but I am getting only first value of that loop, I seen in  
> Template::Manual, Template::Stash, Template::Context, ...
> tried, but not getting solution.

When I run that I get a pile of error messages after the first loop:-
   Use of uninitialized value in substr at /../Provider.pm
     line 1095, <DATA> chunk 1.


That could give you a clue as to whats happening....

Anyhow, you are passing a filehandle to the process() method,
however after the first time through the "file" has been consumed,
but you are not reseting or otherwise dealing with that, so every
loop after the first has an empty template.

You would therefore expect that the output of the second and subsequent
runs would be nothing, except process() is *appending* to the string
reference you passed....

I guess that should help you sort the problem.

        Nigel.

>
> Here is the simple program text,
> ================================\/================================
> #!/bin/env perl
> use Template;
> our $template = Template->new();
> our $txt,
> our %var;
> foreach ( qw/ a b c d e f / ) {
>   $var{"x"} = $_;
>   $template->process(\*DATA, \%var, \$txt);
>   print "value expected ", $_, "\n";
>   print $txt;
> }
> __END__
> value really comming [% x %]
> ================================/\================================
>
> I am getting output
>
> value expected a
> value really comming a
> value expected b
> value really comming a
> ......
> value expected f
> value really comming a
>
> I want it
> value expected a
> value really comming a
> value expected b
> value really comming b
> ......
> value expected f
> value really comming f
>
> Please help to tell how I can get this correct or desired.
> -- 
> Regard,
> Sharad _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates

--
[ Nigel Metheringham             [EMAIL PROTECTED] ]
[ - Comments in this message are my own and not ITO opinion/policy - ]


_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to