<quote who="Stuart Johnston">
> Gavin Henry wrote:
>> <quote who="Andy Wardley">
>>> Gavin Henry wrote:
>>>>     $tt->process( \*DATA, $tt_vars, \$email_output )
>>>>       || die $tt->error(), "\n";
>>> Hi Gavin,
>>>
>>> The problem is here.  The template is only available to be read
>>> from the DATA handle the first time around the loop.  By the second
>>> iteration, the DATA file pointer is already at the EOF and it
>>> effectively looks like a zero-length template.
>>>
>>> Try this instead:
>>>
>>>      local $/ = undef;        # slurp file in one go
>>>
>>>      my $tt = Template->new(  # define named template
>>>          BLOCKS => {
>>>              email => <DATA>,
>>>          },
>>>      );
>>>
>>>      $tt->process('email', ...etc...)
>>
>> Hmmm. It still does the same thing. After the first loop DATA is emtpy,
>> and I get:
>>
>> Odd number of elements in anonymous hash at ./rt_client_reports line 40,
>> <DATA> chunk 1.
>>
>> line 40 being "email => <DATA>," from above.
>>
>> Do I need to rewind the filehandle iterator?
>
> Only the $tt->process... line should be inside the loop.

Ah. I've moved the object creation and $/ out, and not used local, as it's
not local to that loop anymore.

Working fine now!

Thanks,

Gavin.

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


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

Reply via email to