Should Perl's opendir always return . and .. first?
Posted
by ojblass
on Stack Overflow
See other posts from Stack Overflow
or by ojblass
Published on 2010-04-16T15:41:52Z
Indexed on
2010/04/17
13:13 UTC
Read the original article
Hit count: 169
opendir MYDIR, "$dir";
my @FILES = readdir MYDIR;
closedir MYDIR;
It appears that 99.9 % of the time the first two entries in the array are always “.” and “..”. Later logic in the script has issues if it is not true. I ran into a case where the directory entries appeared later. Is this indicative of the file system being corrupt or something else? Is there a known order to what opendir returns?
© Stack Overflow or respective owner