Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: File creation date

by crabbdean (Pilgrim)
on Mar 15, 2004 at 04:05 UTC ( #336596=note: print w/replies, xml ) Need Help??

in reply to File creation date

As far as I'm aware, not really. But I'm curious, why would you want to? A little more info may help us direct you accordingly to an answer. You could try File::stat instead. Check out the module documentation for a synopsis. Other tips:

** in doing stats if you have to stat the same file twice assign the result to a variable for later use
use File::stat; $st = stat($file) or die "No $file: $!";
... and use the $st for any other checks instead of calling stat($file) each time. The reason: each time you call "stat" its a disk IO, which slows things down.

** if you want to know the last time any file in a directory was modified do a stat on the directory. I should contain a modified time of the youngest file. It will save you having to stat the entire subdirectory tree.

** if you are stat'ing lots of files, considering for speed sake refining what you call stat on instead of just stat'ing everything. That is, reduce the amount of files you'll stat by using a search criteria to get rid of 80% of the files you don't need to stat (depending on your needs).

That's all that comes to mind at moment.

The Funkster of Mirth
Programming these days takes more than a lone avenger with a compiler. - sam
RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers

Replies are listed 'Best First'.
Re: Re: File creation date
by saintmike (Vicar) on Mar 15, 2004 at 05:07 UTC
    ... and use the $st for any other checks instead of calling stat($file) each time. The reason: each time you call "stat" its a disk IO, which slows things down.
    BTW, this can also be accomplished using the plain stats command by passing the special parameter _ for subsequent calls:

    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat(_);
    will just grab whatever the last stat($filename) returned without doing unnecessary disc I/O.

    Another thing to point out is that Unix systems don't store the file creation time, their $ctime is inode change time, which is the time the file's meta data on disc last got changed. On Windoze (with the NT filesystem), this is indeed the file creation time, you are correct.


Re: Re: File creation date
by Anonymous Monk on Mar 15, 2004 at 04:49 UTC
    Dean, Thanks for the response. I especially appreciate your performance optimization tips. That hints at the reason I'm trying to use something other than stat. Stat provides me info I don't need and slows me down (although not by much since I'm already in the kernel and already copying to a buffer, copying the extra info would be fast since its consecutive on disk). Also, I was just curious. I thought TMTOWTDI.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://336596]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2017-03-23 23:16 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (294 votes). Check out past polls.