'nobody' using sudo -- scary!

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top