<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7650.28">
<TITLE>Substituição de string e gravação no arquivo</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Palatino Linotype">Pessoal, </FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Palatino Linotype">Tenho um arquivo XML no qual existe a string SNAPSHOT na tag de versão.Preciso encontrar essa tag dentro do arquivo e substituí-la pelo número da versão </FONT></P>

<P><FONT SIZE=2 FACE="Palatino Linotype">salvando o arquivo com essa informação nova.</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Palatino Linotype">Fiz o script de teste abaixo, porém o que esta acontecendo, é ele encontra a string SNAPSHOT, porém não grava nada no arquivo, pior apaga o conteúdo do arquivo inteiro...</FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Palatino Linotype">Please o que estou fazendo de errado:</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Palatino Linotype">#! /usr/bin/perl</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">$local = &quot;arquivoxml.xml&quot;;</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">open (ARQXML,&quot;&lt;$local&quot;);</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">$nome = SNAPSHOT;</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">@texto = &lt;ARQXML&gt;;</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">foreach $matriz (@texto)</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Palatino Linotype">if ($matriz =~ /$nome/)</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=2 FACE="Palatino Linotype"> {</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Palatino Linotype">&nbsp;&nbsp;&nbsp; print $matriz;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Palatino Linotype">&nbsp;&nbsp;&nbsp; $matriz =~ s/$nome/Beta2006.2.1/g;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Palatino Linotype">&nbsp;&nbsp; print ARQXML $matriz;</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=2 FACE="Palatino Linotype">close (ARQXML);</FONT>
</P>

<P><FONT SIZE=2 FACE="Palatino Linotype">ps: sei que o comando de substituição tb está funcionando corretamente pois quando peço apenas para substituir e &quot;printar&quot; em tela funciona, o problema está realmente com o arquivo. Também é valido dizer que já tentei abrir o arquivo com &gt; e &gt;&gt; e acontece a mesma coisa.</FONT></P>

<P><FONT SIZE=2 FACE="Palatino Linotype">TKS galera</FONT>
</P>
<BR>
<BR>

<P><FONT COLOR="#000080" SIZE=2 FACE="Wingdings">b</FONT><FONT COLOR="#000080" SIZE=2 FACE="Palatino Linotype">Paola Montini</FONT>

<BR><FONT COLOR="#000080" SIZE=2 FACE="Palatino Linotype">YMF-Consultoria</FONT>

<BR><FONT COLOR="#000080" SIZE=2 FACE="Palatino Linotype">Fone: 5010-9220</FONT>
</P>

</BODY>
</HTML>