<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
<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='_new'>Crie já o seu!</a></body>
</html>