[Za-pm] Cant get correct count of files in directory :(
Anne Wainwright
anotheranne at fables.co.za
Sun Nov 9 12:18:36 PST 2008
Jonathan et al,
No, I didn't think it would count itself when counting what is in itself :(
I suppose there is a reason for that - something to do with exactly what a filehandle is.
Should of course have looked in my Camel book but just didn't imagine it was a readdir thing.
Thanks for all the replies. I can work with what it does.
bestest
Anne
On Fri, 7 Nov 2008 06:27:39 +0200
Jonathan wrote:
|> 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
--
so much to do, so little time :(
More information about the Za-pm
mailing list