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

Re: trying to count files in a directory and subs

by stevieb (Canon)
on May 19, 2016 at 12:56 UTC ( #1163498=note: print w/replies, xml ) Need Help??


in reply to trying to count files in a directory and subs

Does the following code using File::Find::Rule get you closer to what you want?

use warnings; use strict; use File::Find::Rule; my $dir = 'files'; my $type = '*.psd'; my @files = File::Find::Rule->file() ->name($type) ->in(($dir)); my $count = scalar @files; print "file count: $count\n\n"; print "file names:\n"; print "$_\n" for @files;

Output:

file count: 2 file names: files/a.psd files/subdir/b.psd

Replies are listed 'Best First'.
Re^2: trying to count files in a directory and subs
by flieckster (Scribe) on May 19, 2016 at 17:09 UTC

    yes! that does it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2023-12-06 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (30 votes). Check out past polls.

    Notices?