mecrazycoder has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: File creation and last modifiication time
by moritz (Cardinal) on Aug 21, 2009 at 09:39 UTC
    What have you tried? There's lots of documentation out there, and search engines to find the documentation and lots of other examples.
    Perl 6 projects - links to (nearly) everything that is Perl 6.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: File creation and last modifiication time
by Bloodnok (Vicar) on Aug 21, 2009 at 11:31 UTC
    Following on from moritzs reply, a combination of glob, stat, sort & Date::Calc (with suitable glue code) should suffice ... I'll show you my code, if you show me yours :-D

    A user level that continues to overstate my experience :-))
Re: File creation and last modifiication time
by ikegami (Patriarch) on Aug 21, 2009 at 13:10 UTC
    What OS? unix doesn't track file creation times normally, so Perl doesn't provide a method to get it on systems where it might be supported. A module on CPAN might.

      I don't know what version of UNIX you run but maybe you need to check out man ctime

        I think you mean the st_ctime argument of stat. You should follow your own advise:

        st_ctime
        Time when file status was last changed (inode data modification). Changed by the chflags(2), chmod(2), chown(2), creat(2), link(2), mkdir(2), mkfifo(2), mknod(2), rename(2), rmdir(2), symlink(2), truncate(2), unlink(2), utimes(2), write(2) and writev(2) system calls.
        $ touch a $ perl -MFile::stat -wle'print "".localtime( stat("a")->ctime )' Fri Aug 21 13:31:40 2009 $ sleep 2 $ perl -MFile::stat -wle'print "".localtime( stat("a")->ctime )' Fri Aug 21 13:31:40 2009 $ chmod go= a $ perl -MFile::stat -wle'print "".localtime( stat("a")->ctime )' Fri Aug 21 13:32:25 2009

        I don't know what version of UNIX you run

        The man page is from FreeBSD 7.2. You can view the man pages for about 100 different systems if you follow the link above, and I'm sure you'll find similar results for all of them.

        The example was executed on Debian Linux (etchnhalf)

        $ man -f ctime asctime, asctime_r, ctime, ctime_r, difftime, gmtime, gmtime_r, localtime, localtime_r, mktime, timegm, timelocal (3) - convert date and time to ASCII
        This has nothing about creation time in it. Look here and stat(2) for more details about the lack of creation time. There is mtime (modified - file data change), atime (access time), and ctime (changed time - inode data modifcation).