Oi, patty.<br>
<br>
Tem certeza que o problema está relacionado a ter mais de um arquivo de erros, e não ao conteúdo deles? <br>
<br>
Nem imagino qual seja o problema, pois nunca trabalhei com Templates,
mas posso de tar uma dica de abordagem para identificar o problema:<br>
<br>
Se para o 1o arquivo funciona, tenta colocar no mesmo diretorio somente
ele, com duas cópias. Ou seja, se o arquivo 020107 é o 1o com erro, e o
teu código funciona com ele, cria um diretório vazio para testar,
coloca uma cópia dele com o nome original neste diretório, e outra
cópia com o nome de 020108 por exemplo. Se funcionar com as duas cópias
o teu problema é em relação ao conteúdo dos arquivos (ou forma de lidar
com eles). Se não funcionar, teu problema é outro que não tenho
idéia... ;-)<br>
<br>
Espero ter ajudado.<br>
<br>
Abraço,<br>
&nbsp;&nbsp; Mauricio&nbsp;&nbsp; <br>
<br><br><div><span class="gmail_quote">On 1/9/07, <b class="gmail_sendername">Patty Silva</b> &lt;<a href="mailto:ptfzs@yahoo.com.br">ptfzs@yahoo.com.br</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Ola
Pessoal.. estou usando o Template porem nao estou conseguindo fazer a
gravacao em diversos arquivo ele so grava no 1 arquivo..<br><br>meu codigo resumido.....:<br>Eu leio de um diretorio diversos arquivos e se dentro do arquivo possuir erro ele me gera um LOG ....<br><br>#!/usr/bin/perl<br>
<br><br>use Template;<br>.................<br>opendir (DIR, $basedir) or die &quot;Problemas ao abrir diretorio: $!&quot;;<br><br>while (my $file = readdir(DIR)) <br>{<br>&nbsp;&nbsp;&nbsp; next if $file eq &#39;.&#39; or $file eq &#39;..&#39;;
<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; chdir($dir) || die &quot;\n *** Erro no diretorio $dir ***&quot;;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $file=~ /(\d\d\d\d\d\d)/;<br>&nbsp;&nbsp;&nbsp; $arquivo_saida=&quot;$&quot;.&quot;.log_error&quot;;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <br>&nbsp;&nbsp;&nbsp; open(FH,
 &quot;&lt;$file&quot;) or die(&quot;Nao pode acessar o arquivo&quot;);<br><br>&nbsp;&nbsp;&nbsp; while(&lt;FH&gt;)<br>&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;  .....................................................<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if($bla eq &#39;erro&#39;)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; push @erros, { var =&gt; $nome,data =&gt; $data}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>unlink($file);<br><br><span style="background-color: rgb(255, 255, 0);">chdir($dirlog);
</span><br style="background-color: rgb(255, 255, 0);"><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">$tamanho = @erros;</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">my $data_ref = {</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">&nbsp;&nbsp;&nbsp; erros =&gt; \@erros,
</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">};</span><br style="background-color: rgb(255, 255, 0);"><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
my $t = Template-&gt;new;</span><br style="background-color: rgb(255, 255, 0);"><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">$t-&gt;process(\*DATA,$data_ref,$arquivo_saida);
</span><br><br><br><br>}<br><br>-----------------------------------------------------------------------------------------------------------<br>close(FH);<br>closedir(DIR);<br><br>$dbh-&gt;disconnect();<br><br>dbmclose %DBM;
<br><br><br><span style="background-color: rgb(255, 255, 0);">__DATA__</span><br style="background-color: rgb(255, 255, 0);"><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
ERRO</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">[% FOREACH id = erros %]</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
---------------------------------------------------------------------------------</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">Variavel: [%nome%] Data: [% data %] 
</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">---------------------------------------------------------------------------------</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);">[% END %]</span><br><br><font size="4"><br style="font-weight: bold;"><br style="font-weight: bold;"><span style="font-weight: bold;">Quando tem diversos arquivos ele gera so do 1 e da o seguinte erro nos outros:
</span><br style="font-weight: bold;"><br style="font-weight: bold;"><span style="font-weight: bold;">Use of uninitialized value in substr at <span style="background-color: rgb(191, 0, 95); color: rgb(255, 255, 191);">/usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi/Template/Provider.pm line 1044, &lt;DATA&gt; chunk 1.
</span></span><br style="font-weight: bold;"><br style="font-weight: bold;"><br style="font-weight: bold;"><br style="font-weight: bold;"><span style="font-weight: bold;">Alguem pode dizer o que pode ser??</span><br style="font-weight: bold;">
<br style="font-weight: bold;"><br style="font-weight: bold;"><span style="font-weight: bold;">Obrigada</span></font><br></div></div><span class="ad"><br>__________________________________________________<br>Fale com seus amigos  de graça com o novo Yahoo! Messenger
 <br><a href="http://br.messenger.yahoo.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://br.messenger.yahoo.com/</a> </span></div><span class="ad">
</span><br>_______________________________________________<br>PortoAlegre-pm mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:PortoAlegre-pm@pm.org">PortoAlegre-pm@pm.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mail.pm.org/mailman/listinfo/portoalegre-pm" target="_blank">
http://mail.pm.org/mailman/listinfo/portoalegre-pm</a><br><br></blockquote></div><br>