perl -<br>n (para cada linha do arquivo)<br>a (auto-split)<br>e 'push@array,$F[0]; (inclui o 1o elemento do array criado pelo auto-split)<br>END{print "@array"}' arq.txt<br><br><div><span class="gmail_quote">Em 20/02/08, <b class="gmail_sendername">Fernando Oliveira</b> <<a href="mailto:fernandocorrea@gmail.com">fernandocorrea@gmail.com</a>> escreveu:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
q tal algo assim?<br><code><br>perl -nae 'push@array,$F[0];END{print "@array"}' arq.txt<br></code><br><br><div><span class="gmail_quote">Em 20/02/08, <b class="gmail_sendername">gabriel lima</b> <<a href="mailto:gabriellima333@hotmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">gabriellima333@hotmail.com</a>> escreveu:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><span class="e" id="q_118391e4eacf0ab8_1">
<div>
<span style="font-family: Courier New,Courier,Monospace;">Pessoal, estou com um problema que pode ser fácil de resolver para vocês.</span><br style="font-family: Courier New,Courier,Monospace;"><span style="font-family: Courier New,Courier,Monospace;">Mas eu estou tendo um pouco de dificuldade para resolver o mesmo. Se alguem</span><br style="font-family: Courier New,Courier,Monospace;">
<span style="font-family: Courier New,Courier,Monospace;">me ajudar eu ficarei grato!</span><br style="font-family: Courier New,Courier,Monospace;"><br style="font-family: Courier New,Courier,Monospace;"><span style="font-family: Courier New,Courier,Monospace;">Veja, tenho um arquivo .txt com o seguinte formato</span><br style="font-family: Courier New,Courier,Monospace;">
<br style="font-family: Courier New,Courier,Monospace;"><span style="font-family: Courier New,Courier,Monospace;">63528 Gabriel Lima</span><br style="font-family: Courier New,Courier,Monospace;"><span style="font-family: Courier New,Courier,Monospace;">537728 Outro Nome</span><br style="font-family: Courier New,Courier,Monospace;">
<span style="font-family: Courier New,Courier,Monospace;">645374 Fulano De Tal</span><br style="font-family: Courier New,Courier,Monospace;"><span style="font-family: Courier New,Courier,Monospace;">637485 Beltrano Alvarenga</span><br style="font-family: Courier New,Courier,Monospace;">
<br style="font-family: Courier New,Courier,Monospace;"><span style="font-family: Courier New,Courier,Monospace;">Eu gostaria de ler este arquivo e armazenar, apenas os número, em um $array[$i].<br>Observe que o primeiro número tem um digito a menos que os demais. Este número<br>
tem que ser armazena sem nenhuma espaço em branco, aliás, nenhum pode.<br><br>Para isso eu já tentei de tudo, expressões regulares, usar um while e ficar<br>dando chop até chegar nos números, mas nenhuma das minhas tentavivas deu certo.<br>
Aliás, minhas tacadas de Golf! (como dizem algumas pessoas aqui da lista) passaram<br>bem longe do "buraco".<br><br>#!/usr/bin/perl<br><br>use strict;<br><br>my ($i, @array_emp, $linha);<br><br> # Abrindo arquivo para leitura<br>
open(EMP_LISTA, "< teste.txt") or die "Erro ao abrir arquivo: $!";<br><br> while($linha <EMP_LISTA>){<br> $i = 1;<br> $array_emp[$i] = $linha;<br> $i++;<br> }<br> for($i = 0; $i < 4; $i++){<br>
print "$array_emp[$i]\n";<br> }<br> # Fechando arquivo<br>close(EMP_LISTA);<br><br><br>Era mais ou menos algo como isso que eu estava tentando, mas<br>nem me lembro, escrevi rapido para vocês verem o caminho que <br>
eu estava tomando. Acho que está errado.<br><br>Até mais =/<br><br><br><br><br><br><br></span><br><hr>Conheça já o Windows Live Spaces, o site de relacionamentos do Messenger! <a href="http://www.amigosdomessenger.com.br" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Crie já o seu!</a></div>
<br></span></div>_______________________________________________<br>
Rio-pm mailing list<br>
<a href="mailto:Rio-pm@pm.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Rio-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/rio-pm" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mail.pm.org/mailman/listinfo/rio-pm</a><br></blockquote></div><span class="sg"><br><br clear="all">
<br>-- <br>
[]'s Fernando
</span></blockquote></div><br><br clear="all"><br>-- <br>[]'s Fernando