[SP-pm] Listagem de Arquivos

thiagoglauco at ticursos.net thiagoglauco at ticursos.net
Fri Aug 20 09:34:36 PDT 2010


Cool... o grep estava no lugar errado!!

Quoting Ailton Zacarias <ailtonzsilva em gmail.com>:

> Não Thiago.
>
> Aqui agora tá ok!
>
>
> segue.
>
> ------------------------ CÓDIGO
>
>
>
> use strict;
> use warnings;
>
> my $diretorio="C:/Tmp/e-Mails/ENVIADOS";
> opendir(IMD, $diretorio) || die("Cannot open directory");
> my @thefiles= readdir(IMD);
> closedir(IMD);
>
> my $produrar = 'ALLTASKS';
>
> open(ARQ1,">Lista.html");
> print ARQ1 "<html><head><title>Listagem de arquivos</title></head>\n";
> print ARQ1 "<body><h1>Listagem de Arquivos\n";
>
> my @arquivos = grep(/^$produrar/, em thefiles);
> foreach my $f (@arquivos)
> {
>  unless ( ($f eq ".") || ($f eq "..") )
>  {
>       print ARQ1 "<table><td><a
> href=".$diretorio."/".$f.">".$f."</a></td></table>";
>  }
> }
>
> print ARQ1 "</body></html>\n";
> close(ARQ1);
>
> ------------------------ SAÍDA
>
>
> <html><head><title>Listagem de arquivos</title></head>
> <body><h1>Listagem de Arquivos
> <table><td><a href=C:/Tmp/e-Mails/ENVIADOS/ALLTASKS - MAR
> 003-08.msg>ALLTASKS - MAR 003-08.msg</a></td></table><table><td><a
> href=C:/Tmp/e-Mails/ENVIADOS/ALLTASKS - Planilha MAR
> 028-09.msg>ALLTASKS - Planilha MAR
> 028-09.msg</a></td></table><table><td><a
> href=C:/Tmp/e-Mails/ENVIADOS/ALLTASKS - ROD 061-09.msg>ALLTASKS - ROD
> 061-09.msg</a></td></table><table><td><a
> href=C:/Tmp/e-Mails/ENVIADOS/ALLTASKS MAR 004-08.msg>ALLTASKS MAR
> 004-08.msg</a></td></table><table><td><a
> href=C:/Tmp/e-Mails/ENVIADOS/ALLTASKS MAR 027-08.msg>ALLTASKS MAR
> 027-08.msg</a></td></table></body></html>
>
>
>
>
> Em 20 de agosto de 2010 11:47, <thiagoglauco em ticursos.net> escreveu:
>
>> Pode me explicar isso:
>>
>> my $produrar = 'ALLTASKS';
>>
>> my @arquivos = grep(/^$produrar/, em thefiles);
>>
>> Acho que esta no loop... O codigo modificado abaixo gerou apenas uma saida
>> no meu sistema!!!
>>
>>  use strict;
>>  2 use warnings;
>>  3
>>  4 my $diretorio=".";
>>  5 opendir(IMD, $diretorio) || die("Cannot open directory");
>>  6 my @thefiles= readdir(IMD);
>>  7 closedir(IMD);
>>  8
>>  9 my $produrar = 'teste.c';
>>  10
>>  11 open(ARQ1,">Lista.html");
>>  12 print ARQ1 "<html><head><title>Listagem de arquivos</title></head>\n";
>>  13 print ARQ1 "<body><h1>Listagem de Arquivos\n";
>>  14
>>  15 my @arquivos;
>>  16
>>  17 foreach my $f (@thefiles)
>>  18 {
>>  19  unless ( ($f eq ".") || ($f eq "..") )
>>  20  {
>>  21    @arquivos = grep(/^$produrar/, em thefiles);
>>  22 }
>>  23 }
>>  use strict;
>>  2 use warnings;
>>  3
>>  4 my $diretorio=".";
>>  5 opendir(IMD, $diretorio) || die("Cannot open directory");
>>  6 my @thefiles= readdir(IMD);
>>  7 closedir(IMD);
>>  8
>>  9 my $produrar = 'teste.c';
>>  10
>>  11 open(ARQ1,">Lista.html");
>>  12 print ARQ1 "<html><head><title>Listagem de arquivos</title></head>\n";
>>  13 print ARQ1 "<body><h1>Listagem de Arquivos\n";
>>  14
>>  15 my @arquivos;
>>  16
>>  17 foreach my $f (@thefiles)
>>  18 {
>>  19  unless ( ($f eq ".") || ($f eq "..") )
>>  20  {
>>  21    @arquivos = grep(/^$produrar/, em thefiles);
>>  22 }
>>  23 }
>> 24
>>  25 print "@arquivos";
>>  26 foreach my $Nome(@arquivos)
>>  27  {
>>  28   print ARQ1 "<table><td><a
>>  29 href=".$diretorio."/".$Nome.">".$Nome."</a></td></table>";
>>  30  }
>>  31
>>  32
>>  33
>>  34 print ARQ1 "</body></html>\n";
>>
>> gerou apenas uma saida no meu sistema
>>
>>
>> Quoting Ailton Zacarias <ailtonzsilva em gmail.com>:
>>
>>  Bom dia Amigos
>>>
>>> Gostaria de saber onde estou errando ... pq na listagem de arquivos ele
>>> duplica os nomes de arquivos??? Obrigado!
>>>
>>>
>>> use strict;
>>> use warnings;
>>>
>>> my $diretorio="C:/Tmp/e-Mails/ENVIADOS";
>>> opendir(IMD, $diretorio) || die("Cannot open directory");
>>> my @thefiles= readdir(IMD);
>>> closedir(IMD);
>>>
>>> my $produrar = 'ALLTASKS';
>>>
>>> open(ARQ1,">Lista.html");
>>> print ARQ1 "<html><head><title>Listagem de arquivos</title></head>\n";
>>> print ARQ1 "<body><h1>Listagem de Arquivos\n";
>>>
>>>
>>> foreach my $f (@thefiles)
>>> {
>>>  unless ( ($f eq ".") || ($f eq "..") )
>>>  {
>>>  my @arquivos = grep(/^$produrar/, em thefiles);
>>>
>>   }
>> }
>>
>>> foreach my $Nome(@arquivos)
>>>  {
>>>  print ARQ1 "<table><td><a
>>> href=".$diretorio."/".$Nome.">".$Nome."</a></td></table>";
>>>  }
>>>  }
>>> }
>>>
>>> print ARQ1 "</body></html>\n";
>>> close(ARQ1);
>>>
>>>
>>>
>>>
>>> --
>>> Ailton Zacarias
>>> F4 Computer ? Soluções em Tecnologia da Informação
>>> Tel: 55 +11 4062-0180 (Ailton)
>>> Cel: 55 +11 8405-8334
>>> MSN: ailton em f4computer.com
>>> Skype: ailton.zacarias
>>> http://www.f4computer.com
>>>
>>>
>>
>>
>> _______________________________________________
>> SaoPaulo-pm mailing list
>> SaoPaulo-pm em pm.org
>> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>>
>
>
>
> --
> Ailton Zacarias
> F4 Computer ? Soluções em Tecnologia da Informação
> Tel: 55 +11 4062-0180 (Ailton)
> Cel: 55 +11 8405-8334
> MSN: ailton em f4computer.com
> Skype: ailton.zacarias
> http://www.f4computer.com
>





More information about the SaoPaulo-pm mailing list