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!