Thanx Andy and Mihai, for the inputs.
Regards
Madan kumar Nath
        

On Tue, 16 Oct 2007 17:38:54 +0100, Andy Wardley wrote
> Madan kumar nath wrote:
> > [% PERL %]
> >     my @arr = ("hello", "madan", "kumar");
> >     $context->stash->set('funArgValue',[EMAIL PROTECTED]);
> >     my $yy = $stash->get('funArgValue');
> >     my @yy = @$yy;
> >     print "\nValue in main : @yy\n";
> > 
> >     [%# Function Call %]
> >     [% PROCESS test funArg=funArgValue %]
> > [% END %]
> 
> The template content of a [% PERL %]...[% END %] block is processed
> *before* it is evaluated as Perl. So the PROCESS is being done first,
> and the output it generates is then evaluated as part of the PERL
> expression.
> 
> Here's a simple example to show what I mean.
> 
>    [% name = 'World' %]
>    [% PERL %]
>       print "Hello [% name %]";
>    [% END %]
> 
> This is the same thing as:
> 
>    [% PERL %]
>       print "Hello World";
>    [% END %]
> 
> Which ultimately becomes (in Perl)
> 
>    eval {
>       print "Hello World";
>    };
> 
> As Mihai points out in his reply, you should be doing this instead of
> the PROCESS directive.
> 
>    $context->process('test', { funArg => [EMAIL PROTECTED] });
> 
> This performs the equivalent of the [% PROCESS test 
> funArg=funArgValue %] directive, and it will happen at the right 
> time, i.e. in the PERL block, after funArgValue has been set.
> 
> Alternately, if it's just defining Perl data that you want to do then
> you can do most things direct from TT without needing a PERL block 
> at all.
> 
> e.g.
> 
>    [% funArgValue=["hello", "madan", 'kumar"] %]
>    [% PROCESS test funArg=funArgValue %]
> 
> Or even:
> 
>    [% PROCESS test funArg=["hello", "madan", 'kumar"] %]
> 
> If you really do need a PERL block, and you also want to use the PROCESS
> directive, then do this instead:
> 
>   [% PERL %]
>       my @arr = ("hello", "madan", "kumar");
>       $context->stash->set('funArgValue',[EMAIL PROTECTED]);
>   [% END %]
> 
>   [% PROCESS test funArg=funArgValue %]
> 
> HTH
> A


--Madan Kumar Nath


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

Reply via email to