Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Epoch mod time for files

by Rhose (Priest)
on Mar 05, 2002 at 15:38 UTC ( #149400=note: print w/replies, xml ) Need Help??


in reply to Epoch mod time for files

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://149400]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2019-08-21 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?