mbeason has asked for the wisdom of the Perl Monks concerning the following question:
I've also tried doing a if(-M $mksysb); as well after the "next" line but with no luck. If I put a print statment before the $curr_time declaration, I get a listing of the files so I know at least that part is working. HELP!use File::stat; use Time::Local; chomp(my $host = `hostname`); my($timestamp) = strftime "%Y%m%d", localtime; my($humantime) = strftime "%c", localtime; my($standard_days) = 7; my($mksysb_cutoff) = (time() - ($standard_days*86400)); # now - standa +rd_days_seconds &cleanup; sub cleanup { opendir(MOUNT, "/mnt") or die "Cannot open directory: $!"; @mksysb_list = readdir MOUNT; closedir MOUNT; foreach my $mksysb (@mksysb_list) { next if($mksysb eq ".") or ($mksysb eq "..") or ($mksysb eq "l +ost+found"); if($mksysb =~ /\d+\.$host\.mksysb/) { my $curr_time=(stat("$mksysb"))[9]; if ($curr_time < $mksysb_cutoff) { print "I would have deleted |$mksysb|!\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Compare mtime?
by xdg (Monsignor) on Mar 14, 2006 at 19:41 UTC | |
by mbeason (Novice) on Mar 14, 2006 at 19:49 UTC | |
|
Re: Compare mtime?
by rafl (Friar) on Mar 14, 2006 at 19:43 UTC | |
|
Re: Compare mtime?
by Zaxo (Archbishop) on Mar 14, 2006 at 20:02 UTC | |
|
Re: Compare mtime?
by smokemachine (Hermit) on Mar 14, 2006 at 20:09 UTC |