1 2 3 4 5 6 7 8 9 10 11 12 13 14
use File::Find; my @found; # gefundene Dateinamen find (\&found, $dir); sub found { my $fn = $File::Find::name; if (-f $fn && $fn !~ /\.gz$/ # kein .gz && (stat($fn))[10] == +time-86400) { # ctime == Jetztzeit - 1 day push @found,$fn; # gefunden, dann ins Array } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
use DateTime; use File::Find; # gefundene Dateinamen my @found; find (\&found, $dir); # Gestern 00:00:00 als Unixepoche (in Sekunden) my $yesterepoch = DateTime->today->add(days => -1)->epoch; sub found { my $fn = $File::Find::name; my $stat; if ( -f $fn # kein *.gz && $fn !~ /\.gz$/ # gestern 00:00:00 && ($stat = (stat($fn))[10]) >= $yesterepoch # gestern 23:59:59 && $stat <= $yesterepoch+86400-1 ) { push @found,$fn; # gefunden, dann abs ins Array } } print join "\n",@found;
1 2 3 4 5 6 7 8 9 10
use Class::Date 'date'; use constant CTIME => 10; for my $filepath (glob('/foo/*')) { next if $filepath =~ /\.gz$/; next if date((stat($filepath))[CTIME])->truncate eq (date(time) - '1D')->truncate; print "$filepath\n"; }