On 3/16/10 Tue Mar 16, 2010 12:18 PM, "ben perl" <ben.pe...@gmail.com> scribbled:
> Hi Everyone, > > I writing this program to check if a file is being touched (linux "touch" > command) every 25 seconds.I am using stat command on linux. > > For example(please check the bold), > > stat file > File: `file' > Size: 0 Blocks: 0 IO Block: 4096 regular empty > file > Device: 803h/2051d Inode: 164394 Links: 1 > Access: (0666/-rw-rw-rw-) Uid: ( 0/ admin) Gid: ( 0/ root) > Access: 2010-03-16 12:09:03.000000000 -0700 > Modify: 2010-03-16 12:09:03.000000000 -0700 > Change: *2010-03-16 *12:09:03.000000000 -0700 <= > > I am just worried about the change attribute above from stat command. So , > what i am trying to do convert 12:09:03(as in the example above) into > seconds and add 25 seconds and convert back into "hour:minutes:seconds" > format and check the values match. If you are writing a Perl program, you can use the Perl built-in stat function that returns 'last modify time' in seconds from the epoch (1/1/70:00:00:00 UTC), rather than the Linux stat command as above. That way, you can easily compare times numerically and not worry about converting between numerical and string forms. See 'perldoc -f stat' for details. There is also the -M file test operator that returns the age (difference between the time your program started and the time the file was modified) of any file in floating-point days (multiply by 86,400 to get age in seconds). See 'perldoc -f -X' for details. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/