http://qs321.pair.com?node_id=479789


in reply to time difference

Untested code follows ... Update: Bugger, caught out on inode change/creation time - Remember that (stat _)[10] (or -C _) is not file creation time, but rather inode change time.
sub diff { return -1 unless -e $_[0]; my @result = (); my $diff = ((stat _)[10]) - ((stat _)[9]); foreach my $time ((86400, 3600, 60, 1)) { push @result, $diff % $time; $diff -= $result[-1]; } return @result; }

 

perl -le "print unpack'N', pack'B32', '00000000000000000000001000000000'"

Replies are listed 'Best First'.
Re^2: time difference
by mifflin (Curate) on Aug 01, 2005 at 05:02 UTC
    Is there a reliable way to get the true file creation time given that -C (and stat 10) is not it?
      Not in Unix. The Unix founders argue (and I agree) that "creation time" is at best an odd concept. But you didn't say on what platform, so you may be able to get a "fake" creation time proposed by your platform.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        The Unix founders argue (and I agree) that "creation time" is at best an odd concept.

        Care to explain that?

        dir thisfile File not found. echo . > thisfile dir thisfile 01/08/2005 06:38 4 thisfile

        The file was created. The time tells you when it was created. How is that false or ambiguous?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.