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

Re: trying to count files in a directory and subs

by stevieb (Canon)
on May 19, 2016 at 16: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 21: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? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2022-06-26 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (83 votes). Check out past polls.

    Notices?