Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Read Directory and getlines in .csv

by Ovid (Cardinal)
on Apr 27, 2016 at 17:12 UTC ( #1161660=note: print w/replies, xml ) Need Help??


in reply to Read Directory and getlines in .csv

I know not everyone is a fan of File::Find::Rule, but I'm so used to it that it's just a quick hack for me. The following returns a list of all files with a .csv extension, in a given directory, modified within the last 24 hours. The rest, of course, should be straightforward after this.
use File::Find::Rule; my $dir = 'lib'; # or wherever they're located my $last_24_hours = time - 86_400; my @files = File::Find::Rule->file->name('*.csv')->mtime(">$la +st_24_hours")->in($dir);

Replies are listed 'Best First'.
Re^2: Read Directory and getlines in .csv
by Cristoforo (Curate) on Apr 27, 2016 at 20:14 UTC
    Note that this will recurse into subdirectories of $dir if they exist. His code does not.

    I'm not sure how you could achieve that.

    Update: I believe this addition to the rule will achieve that.

    my @files = File::Find::Rule->file->name('*.csv')->maxdepth(1)->mtime(">$last_24_hours")->in($dir);

    Update: poj's use of glob would probably be the better solution

Re^2: Read Directory and getlines in .csv
by Dipepper (Novice) on Apr 27, 2016 at 17:24 UTC

    Great idea to use File::Find::Rule Thank you!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2020-10-26 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (253 votes). Check out past polls.

    Notices?