Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Epoch mod time for files

by Rhose (Priest)
on Mar 05, 2002 at 15:38 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://149400]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-24 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found