<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><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 "Problemas ao abrir diretorio: $!";<br><br>while (my $file = readdir(DIR)) <br>{<br>&nbsp;&nbsp;&nbsp; next if $file eq '.' or $file eq '..';<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; chdir($dir) || die "\n *** Erro no diretorio $dir ***";<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; $file=~ /(\d\d\d\d\d\d)/;<br>&nbsp;&nbsp;&nbsp; $arquivo_saida="$".".log_error";<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <br>&nbsp;&nbsp;&nbsp; open(FH,
 "&lt;$file") or die("Nao pode acessar o arquivo");<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 'erro')<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><br>__________________________________________________<br>Fale com seus amigos  de graça com o novo Yahoo! Messenger
 <br>http://br.messenger.yahoo.com/ </body></html>