Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Gather file count in directory

by ~~David~~ (Hermit)
on Jan 05, 2012 at 14:22 UTC ( #946406=note: print w/replies, xml ) Need Help??

in reply to Gather file count in directory

I always like the File::Slurp module.
use File::Slurp; my $dir = 'somedir'; my @files = read_dir( $dir ); my $num_of_files = scalar @files;

Replies are listed 'Best First'.
Re^2: Gather file count in directory
by mr.nick (Chaplain) on Jan 05, 2012 at 18:14 UTC
    If you're willing to slurp in the entire filelist, you can also do
    my $num_of_files = scalar @{[<*>]};

    mr.nick ...

Re^2: Gather file count in directory
by Anonymous Monk on Jan 06, 2012 at 06:24 UTC

    The File::Slurp method is not giving the total number of files in a drive (as in C:// etc). It only gives an upper count of the files in directory doesnt give the count of files in folders ..

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946406]
and a moth chases the moon...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2017-12-17 04:58 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (462 votes). Check out past polls.