in reply to Re: Counting only certain files...
in thread Counting only certain files...

I think using grep() or glob() in this case is a total overkill. You are not going to use filenames afterwards, so there is no need to allocate all that memory just to throw away the result.
my $total = 0; opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $k +ey could not be opened."); while ($_ = readdir DIR){$total++ if -f and /\d/o } closedir DIR;
--perlplexer

Replies are listed 'Best First'.
Re: Re: Re: Counting only certain files...
by SysAdm (Novice) on May 18, 2001 at 09:26 UTC
    I went with this...

    my $numfiles = 0; opendir DIR, "$config{'basepath'}$key" or &oops("Category +directory $key could not be opened."); readdir DIR;readdir DIR; while ($_ = readdir DIR){$numfiles++ if /\d.dat/o } closedir DIR;


    My files actually end with .dat, therefore I added the extension...

    I want to thank you all for your help... GOD I love this site... (no pun intended!)

    _______SysAdm