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: Size of file
    ... snip ... ... standard C). ... There is no reason a user can't write his own stat() ... Topicality doesn't preclude using a little common sense. ...
    (comp.lang.c)
  • 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: Error or compiler bug?
    ... mecej4 wrote: ... integer, optional, intent:: stat ... It might be that this is new in Fortran 2003, ...
    (comp.lang.fortran)
  • Re: [OT] Is stat function thread safe ?
    ... but if it is so is implementation dependent. ... since there is no description of a stat function in the C ... standard. ...
    (comp.lang.c)
  • 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)