<div>Se você está no foreach, pq passa todo o array no grep ?</div><div><br></div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><span class="Apple-style-span" style="border-collapse: separate; font-size: small;">tente substituir isso: <span class="Apple-style-span" style="font-size: 13px; border-collapse: collapse; "> @arquivos = grep(/^$produrar/,@thefiles);</span></span></span><div>
<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><span class="Apple-style-span" style="border-collapse: separate; font-size: small;"><span class="Apple-style-span" style="border-collapse: collapse;">por isso: <span class="Apple-style-span" style="font-size: 13px; ">@arquivos = grep(/^$produrar/,$_);</span></span></span></span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">> Pode me explicar isso:<br>
><br>> my $produrar = 'ALLTASKS';<br>><br>> my @arquivos = grep(/^$produrar/,@thefiles);<br>><br>> Acho que esta no loop... O codigo modificado abaixo gerou apenas uma saida<br>> no meu sistema!!!<br>
><br>> use strict;<br>> 2 use warnings;<br>> 3<br>> 4 my $diretorio=".";<br>> 5 opendir(IMD, $diretorio) || die("Cannot open directory");<br>> 6 my @thefiles= readdir(IMD);<br>
> 7 closedir(IMD);<br>> 8<br>> 9 my $produrar = 'teste.c';<br>> 10<br>> 11 open(ARQ1,">Lista.html");<br>> 12 print ARQ1 "<html><head><title>Listagem de arquivos</title></head>\n";<br>
> 13 print ARQ1 "<body><h1>Listagem de Arquivos\n";<br>> 14<br>> 15 my @arquivos;<br>> 16<br>> 17 foreach my $f (@thefiles)<br>> 18 {<br>> 19 unless ( ($f eq ".") || ($f eq "..") )<br>
> 20 {<br>> 21 @arquivos = grep(/^$produrar/,@thefiles);<br>> 22 }<br>> 23 }<br>> use strict;<br>> 2 use warnings;<br>> 3<br>> 4 my $diretorio=".";<br>> 5 opendir(IMD, $diretorio) || die("Cannot open directory");<br>
> 6 my @thefiles= readdir(IMD);<br>> 7 closedir(IMD);<br>> 8<br>> 9 my $produrar = 'teste.c';<br>> 10<br>> 11 open(ARQ1,">Lista.html");<br>> 12 print ARQ1 "<html><head><title>Listagem de arquivos</title></head>\n";<br>
> 13 print ARQ1 "<body><h1>Listagem de Arquivos\n";<br>> 14<br>> 15 my @arquivos;<br>> 16<br>> 17 foreach my $f (@thefiles)<br>> 18 {<br>> 19 unless ( ($f eq ".") || ($f eq "..") )<br>
> 20 {<br>> 21 @arquivos = grep(/^$produrar/,@thefiles);<br>> 22 }<br>> 23 }<br>> 24<br>> 25 print "@arquivos";<br>> 26 foreach my $Nome(@arquivos)<br>> 27 {<br>> 28 print ARQ1 "<table><td><a<br>
> 29 href=".$diretorio."/".$Nome.">".$Nome."</a></td></table>";<br>> 30 }<br>> 31<br>> 32<br>> 33<br>> 34 print ARQ1 "</body></html>\n";<br>
><br>> gerou apenas uma saida no meu sistema<br>><br>><br>> Quoting Ailton Zacarias <<a href="mailto:ailtonzsilva@gmail.com" style="color: rgb(0, 0, 204); ">ailtonzsilva@gmail.com</a>>:<br>><br>> Bom dia Amigos<br>
>><br>>> Gostaria de saber onde estou errando ... pq na listagem de arquivos ele<br>>> duplica os nomes de arquivos??? Obrigado!<br>>><br>>><br>>> use strict;<br>>> use warnings;<br>
>><br>>> my $diretorio="C:/Tmp/e-Mails/ENVIADOS";<br>>> opendir(IMD, $diretorio) || die("Cannot open directory");<br>>> my @thefiles= readdir(IMD);<br>>> closedir(IMD);<br>
>><br>>> my $produrar = 'ALLTASKS';<br>>><br>>> open(ARQ1,">Lista.html");<br>>> print ARQ1 "<html><head><title>Listagem de arquivos</title></head>\n";<br>
>> print ARQ1 "<body><h1>Listagem de Arquivos\n";<br>>><br>>><br>>> foreach my $f (@thefiles)<br>>> {<br>>> unless ( ($f eq ".") || ($f eq "..") )<br>
>> {<br>>> my @arquivos = grep(/^$produrar/,@thefiles);<br>>><br>> }<br>> }<br>><br>>> foreach my $Nome(@arquivos)<br>>> {<br>>> print ARQ1 "<table><td><a<br>
>> href=".$diretorio."/".$Nome.">".$Nome."</a></td></table>";<br>>> }<br>>> }<br>>> }<br>>><br>>> print ARQ1 "</body></html>\n";<br>
>> close(ARQ1);<br>>><br>>><br>>><br>>><br>>> --<br>>> Ailton Zacarias<br>>> F4 Computer ? Solu??es em Tecnologia da Informa??o<br>>> Tel: 55 +11 4062-0180 (Ailton)<br>
>> Cel: 55 +11 8405-8334<br>>> MSN: <a href="mailto:ailton@f4computer.com" style="color: rgb(0, 0, 204); ">ailton@f4computer.com</a><br>>> Skype: ailton.zacarias<br>>> <a href="http://www.f4computer.com/" target="_blank" style="color: rgb(0, 0, 204); ">http://www.f4computer.com</a><br>
>><br>>><br>><br>><br>> _______________________________________________<br>> SaoPaulo-pm mailing list<br>> <a href="mailto:SaoPaulo-pm@pm.org" style="color: rgb(0, 0, 204); ">SaoPaulo-pm@pm.org</a><br>
> <a href="http://mail.pm.org/mailman/listinfo/saopaulo-pm" target="_blank" style="color: rgb(0, 0, 204); ">http://mail.pm.org/mailman/listinfo/saopaulo-pm</a><br>></span>
</div>