[]s<br><br><b><i>Luis Motta Campos <luismottacampos@yahoo.co.uk></i></b> escreveu:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> On May 9, 2007, at 2:15 PM, Patty Silva wrote:<br>> Luis.. :D<br>> Eu 1 verifico se o arquivo existe...<br>> se ele existir eu vou "ACRESCENTAR" dados no arquivo<br>> if(-e "$dirlog/$dir/$log_error")<br>> {<br>> print "ARQUIVO EXISTE\n";<br>> open my $FH1, ">>", $out or die "Nao foi Possivel Abrir o <br>> Arquivo: $!";<br>> $t->process( \$input, $ref, $\out ) or die $template->error();<br>><br>><br>> }<br>> else<br>> {<br>> print "ARQUIVO NAO EXISTE\n";<br>> $t->process( \$input, $ref, $out ) or die $template->error();<br>><br>> }<br>><br>> massssss nao funcionou.. ele imprime o nome do arquivo ...<br>> :D<br>> o q eu percebi foi que o
$t->process( \$input, $ref, $\out ) ele <br>> cria outro arquivo.. independente de ja existir ou nao...<br><br> O manual do Template diz o seguinte:<br><br> A third parameter may be passed to the process() method to specify a<br> different output location. This value may be one of:<br> * a plain string indicating a file-name which will be opened<br> (relative to OUTPUT_PATH, if defined) and the output written <br>to;<br> * a file GLOB opened ready for output;<br> * a reference to a scalar (e.g. a text string) to which output/ <br>error is appended;<br> * a sub routine reference;<br> * any objetc reference that implements the print() method<br><br> Assim, vamos nos aproveitar da segunda alternativa (FILEHANDLE <br>GLOB), e implementar assim:<br><br> # Não precisa mais testar para saber se existe arquivo ou não, <br>apenas abre em modo APPEND:<br><br> open my $FH, '+>', $out<br> or die "$!";<br>
$template->process( \$input, $ref, $FH )<br> or die $template->error;<br> close $FH<br> or die "$!";<br><br> E isso basta para todos os casos.<br><br> Por favor tenta ler o manual com mais calma... ;-)<br> Putamplexos!<br>--<br>Luis Motta Campos (a.k.a. Monsieur Champs) is a software engineer,<br>Perl fanatic evangelist, and amateur {cook, photographer}<br><br><br>_______________________________________________<br>Cascavel-pm mailing list<br>Cascavel-pm@pm.org<br>http://mail.pm.org/mailman/listinfo/cascavel-pm<br></blockquote><br><p> __________________________________________________<br>Fale com seus amigos de graça com o novo Yahoo! Messenger <br>http://br.messenger.yahoo.com/