H
Hans Mulder
The first call to readdir() in scalar context will read the entire list
into memory and return just the first one. Succeeding calls to
readdir() in scalar context will return the next one from the buffer.
Either way, you'll still end up having the whole list in memory.
That will only happen if the directory if fairly small. Readdir uses a
fixed-size buffer (typically 8kB). On the first call in scalar context,
it reads a bunch of entries into the buffer and returns the filename
from the first entry. On subsequent calls, it returns filenames from
the other entries in the buffer, until the buffer is exhausted, then
it reads the second bunch of entries into the buffer, etc.
Hope this helps,
-- HansM