"Unix directories are lists of 'link' structures"
From http://en.wikipedia.org/wiki/Inod开发者_运维问答e
Unix directories are lists of "link" structures, each of which contains one filename and one inode number.
I'd like to just get the length of this list of links, the names of the files in the directory aren't important at this point in my code.
A solution in Perl would be preferred, but any solution will do.
opendir DIR, '.';
$num_items = @{[readdir DIR]};
closedir DIR;
The central point is that readdir
returns all the directory entries when called in list context.
精彩评论