Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Looking for small csv files script question

by dasgar (Deacon)
on Dec 04, 2013 at 14:45 UTC ( #1065599=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Looking for small csv files script question
in thread Looking for small csv files script question

In sticking with the core modules so that you don't have to install any new modules, here's some untested code that is basically a modified version of what Tux provided that handles your new requirement.

use File::Find; use File::Basename; use feature 'say'; my @files; find (sub { m/\.csv$/i && -s $_ < 5500 and push @files, $File::Find::N +ame }, "C:/Temp"); my %dirs; foreach my $file (@files) { my($filename, $directories, $suffix) = fileparse($file); $dirs{$directories}++; } my @keys = keys %dirs; @keys = sort @keys; foreach my $key (@keys) {say $key;}

Basically, what I've done is taken the array of files that meet your criteria and then putting their path (minus filename) into a hash where the path is a key in the hash (and the value for the key is the count of files in that folder that meet your criteria). Then I'm sorting the keys and printing them out. Hopefully, this will help get your further into solving your problem.


Comment on Re^3: Looking for small csv files script question
Download Code
Re^4: Looking for small csv files script question
by PerlPlay (Novice) on Dec 05, 2013 at 06:28 UTC

    Hi Dasgar

    Thanks for your response - again. :-)

    Question for you though, I'm still a newbie trying to decipher shortned subs, where would I put a print statement or say in your find (sub... line?

    I'd like to actually see when it finds a suspect folder instead of waiting for it to finish before it displays the suspect folders. I have quite a number of folders and it does take a while to run.

      Worked it out for myself...

      find (sub { m/\.csv$/i && -s $_ < 5500 and print "$File::Find::name\n" + and push @files, $File::Find::name }, $dir);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-08-31 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls