in reply to Reading a directory and getting file dates

Try this:
opendir(DIR,"/home/user/ptest"); while($dir=readdir(DIR)) { if(($dir ne ".")&&($dir ne "..")) { if(-d "/home/user/ptest/$dir") { ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $ati +me,$mtime,$ctime,$blksize,$blocks)=stat("/home/user/ptest/".$dir); print "FILE: ".$dir." Time: $mtime\n"; } } }

Replies are listed 'Best First'.
Re: Reading a directory and getting file dates
by b10m (Vicar) on Jun 01, 2005 at 20:55 UTC

    If all you want is the $mtime, you might as well use this:

    my $mtime = (stat("/home/user/ptest/$dir"))[9];

    ...at least it's easier to read ;)

    --
    b10m

    All code is usually tested, but rarely trusted.
      Very true :)...I was a little too eager on the reply :), but at least it shows the available info one can get from 'stat'...
        but at least it shows the available info one can get from 'stat'

        A simple link to stat would do that too, and probably be even more helpful ;)

        --
        b10m

        All code is usually tested, but rarely trusted.