Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Counting only certain files...

by perlplexer (Hermit)
on May 17, 2001 at 21:37 UTC ( [id://81309]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://81309]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found