Re: file access dates



wellercs@xxxxxxxxx wrote:
Hi, I am new to perl, and I want to search a root directory and find
files that have not been accessed within the last 6 months. I have
found that the stat function returns an array of file info. Could
someone please tell me which element the last accessed date is?

Yes, the authors of the documentation can tell you that.
stat Returns a 13-element list giving the status info for
a file,
<snip>
Not all fields are supported on all filesystem
types. Here are the meanings of the fields:

<snip>
8 atime last access time in seconds since the epoch
<snip>



Also
if there is a better way than using stat, please point me in the right
direction.

Again, please check the documenation for the function you're using,
before asking thousands of people around the world to read it to you:
The File::stat module provides a convenient, by-name
access mechanism:

use File::stat;
$sb = stat($filename);
printf "File is %s, size is %s, perm %04o, mtime
%s\n",
$filename, $sb->size, $sb->mode & 07777,
scalar localtime $sb->mtime;


Paul Lalli

.



Relevant Pages

  • Re: stat() bug
    ... >> I know that this is not the proper usage of the stat function, ... contents of @myarray after the print to verify). ...
    (comp.lang.perl.misc)
  • Re: Unable to read timestamp for remote files
    ... statlooks for a file on your local machine. ... What's wrong is that you're calling stat() on a filename that doesn't ...
    (perl.beginners)
  • Re: How to detect an empty file?
    ... Olivier wrote: ... just use stat(). ... What sort of entry is it ...
    (comp.lang.c)
  • Re: How to detect an empty file?
    ... you could have at least said fstat() ... to be closer to the normal C I/O library. ... BTW saying "stat" isn't portable is kinda moot since not all platforms ... So very likely using some stat function is ...
    (comp.lang.c)
  • Bush Supporter Selected at Random WAS Re: Kerrys Blah Blah Blah
    ... Based on the sampling of SED, the official stat is that Bush supporter ... Tom Seim wrote: ... [..snip elementary trash...] ...
    (sci.electronics.design)