I am trying to find files younger than 24 hours old in the /tmp directory.
-------------------------------
#!/usr/bin/perl -w
use strict;
use File::stat ;
opendir(D, "/tmp") or die $!;
my $time = time();
while (my $f = readdir(D)) {
next if $f =~ /^\./;
next unless $f =~ /^log/ ;
my ($atime, $mtime, $ctime) = (stat($f))[8..10];
my $age_hours = ($time - $mtime) / 3600 ;
next unless $age_hours < 24 ;
print "---> $f \n" ;
}
closedir(D);
---------------------------
The above script simply doesnt work for me.
-------------------------------
#!/usr/bin/perl -w
use strict;
use File::stat ;
opendir(D, "/tmp") or die $!;
my $time = time();
while (my $f = readdir(D)) {
next if $f =~ /^\./;
next unless $f =~ /^log/ ;
my ($atime, $mtime, $ctime) = (stat($f))[8..10];
my $age_hours = ($time - $mtime) / 3600 ;
next unless $age_hours < 24 ;
print "---> $f \n" ;
}
closedir(D);
---------------------------
The above script simply doesnt work for me.