in reply to Read Directory and getlines in .csv
I realized I am checking for modified date twice. I have corrected my code.
#!/usr/bin/perl use strict; use warnings; use File::stat; use Text::CSV_XS; use IO::File; my $dirname = "Daily_QoS_CPD_link"; opendir(DIR, $dirname) or die "Not able to open $dirname $!"; # Create an array of files in directory my @dir = grep /\.csv/, $dirname ne '.' && $dirname ne '..', readdi +r DIR; rewinddir(DIR); # create a list of csv's for today into a text file. my $One_day = 86400; foreach my $list (@dir){ my $diff = time()-stat("$dirname/$list")->mtime; if( $One_day > $diff){ open FILE, ">>CPD_Files.txt" or die "Not able to open f +ile $!"; print FILE "$list\n"; } } closedir DIR; close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read Directory and getlines in .csv
by Cristoforo (Curate) on Apr 27, 2016 at 16:45 UTC | |
by Anonymous Monk on Apr 27, 2016 at 16:57 UTC | |
by Dipepper (Novice) on Apr 27, 2016 at 17:27 UTC |