By doing a little playing around, I got it to work like this:

 my $template_params = {
        device           => $params->{device},
        empty_hash   => {},
        result             => $result
    };

then in my template
...
my $hash = $stash->get('empty_hash');
$hash->{'log_date'} = $log_date;
$stash->set('empty_hash', $hash);
...

then after process

$VAR1 = {
'empty_hash' => {
   'log_date' => '2192011'
}
....

On Sat, Feb 19, 2011 at 12:37 PM, Josh803316 <[email protected]> wrote:

> As talked about here:
> http://www.perlmonks.org/?node_id=641731
> One of the posters says this issue was discussed before on the mailing list
> but I couldn't find the topic.
>
> In the following code, my $expected_result template is actually a [% PERL
> %] block.  Inside the block I access result and device using
> $stash->get('result')...
> I was wondering if there was any way for me to modify the passed variable
> $template_attributes with the result of something done inside the template
> block.
>
> I tried
> $stash->set('log_date', $log_date);  # So that I could keep track of a date
> based on some perl calculations inside the template
>
> but I realized that once process was finished it wasn't saved...........
>
> So my question:
> *Is there any current way using TT that I can set/save variable values for
> use once process is finished?*
>
>
>     my $template_attributes = {
>         device          => $params->{device},
>         result           => $result
>     };
>
>     my $expected_result_output;
>     $template->process(\$expected_result, $template_attributes,
> \$expected_result_output)
>      || die $template->error();
>
>     die(Dumper($template_attributes));  # Can $template_attributes include
> 'log_date' after the template block is processed?
>
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to