[Za-pm] Cant get correct count of files in directory :(

Jonathan McKeown jonathan at hst.org.za
Thu Nov 6 20:27:39 PST 2008


On Thursday 06 November 2008 22:56, Anne Wainwright wrote:
> Hi,
>
> Stupid count!
>
> # get a list of filenames in current directory into an array
> opendir (THISDIR, ".") or die "serious brain damage: $!";
> @allfiles = readdir (THISDIR);
> closedir (THISDIR);
> $howmany = @allfiles;
> print "\tthere are $howmany files in the array\n\n";
>
> At this point it outputs a count of 133 files in the array
>
> I count 125 + 1 hidden @ file + 5 subdirectories + the parent /..  = 132
>
> I am sure my trusty Midnight Commander can count the files. Am I having a
> blonde moment?

Stupid question - did you count . , the directory itself? readdir does.

Jonathan


More information about the Za-pm mailing list