Here is some code I have used to find out how many seconds old a specified file(s) is.
#!/usr/bin/perl -w
use strict;
#-- Use modules
use File::stat;
use Time::Local;
use Time::localtime;
#-- Define local constants
#-- Define local variables
my $lNow;
my $lStat;
#-- Initialize variables
$lNow=localtime();
$lNow=timelocal($lNow->sec,$lNow->min,$lNow->hour,$lNow->mday,$lNow->m
+on,$lNow->year);
#-- Process all files
foreach (@ARGV)
{
#-- Get the file's status
$lStat=stat($_) || die 'Could not stat file ['.$_.']...';
#-- Print the time
print $_,"\t",($lNow-$lStat->mtime()),' seconds old',"\n";
}
#-- End of Script
I hope this helps.