in reply to Re^2: some problem with date
in thread some problem with date
use strict; use warnings; use Date::Calc qw( Delta_Days ); use File::Spec qw( catfile ); my ($y, $m, $d) = (localtime())[5, 4, 3]; $y += 1900; $m += 1; my $dir = ...; opendir(my $dh, $dir) or die("Unable to open log dir \"$dir\": $!\n"); while (my $file_name = readdir($dh)) { my $file_full = catfile($dir, $file_name); next if ! -f $file_full; my $mtime = (stat($file_full))[9]; my ($fy, $fm, $fd) = (localtime($mtime))[5, 4, 3]; $fy += 1900; $fm += 1; my $delta_days = Delta_Days(($y, $m, $d), ($fy, $fm, $fd)); if ($delta_days == 1) { ...copy the file... } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: some problem with date
by Anonymous Monk on Apr 16, 2007 at 10:21 UTC | |
by ikegami (Patriarch) on Apr 16, 2007 at 13:53 UTC | |
by Anonymous Monk on Apr 17, 2007 at 06:49 UTC | |
by ikegami (Patriarch) on Apr 17, 2007 at 13:46 UTC |