foreach my $f (readdir DH) { ... }<div><br></div><div>seria aproximadamente equivalente a</div><div><br></div><div>my @f = readdir DH;</div><div>foreach my $f (@f) { ... }</div><div><br></div><div>Ou seja, todos os resultados são pré-carregados e depois enumerados.</div>

<div>Mais lento não fica, mas definitivamente consome mais memória.<br><div><br>ABS()<br><br>
<br><br><div class="gmail_quote">On Wed, Apr 11, 2012 at 09:52, Ednardo Lobo <span dir="ltr"><<a href="mailto:ednardo@lobo.eti.br">ednardo@lobo.eti.br</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Uma curiosidade que tenho ...<br>
<br>
Em termos de processamento e uso de memória, há alguma diferença entre:<br>
<br>
foreach my $f (readdir DH) {<br>
...<br>
}<br>
<br>
e<br>
<br>
while (my $f = readdir DH) {<br>
...<br>
}<br>
<br>
<br>
readdir DIRHANDLE<br>
     Returns the next directory entry for a directory opened by<br>
     "opendir".  If used in list context, returns all the rest of<br>
     the entries in the directory.  If there are no more entries,<br>
     returns an undefined value in scalar context or a null list in<br>
     list context.<br>
<br>
<br>
Grato,<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
    Ednardo Lobo<br>
<br>
    <a href="http://www.lobo.eti.br" target="_blank">www.lobo.eti.br</a><br>
______________________________<u></u>_________________<br>
Cascavel-pm mailing list<br>
<a href="mailto:Cascavel-pm@pm.org" target="_blank">Cascavel-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/cascavel-pm</a><br>
</font></span></blockquote></div><br></div></div>