Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Reading a directory and getting file dates

by cool_jr256 (Acolyte)
on Jun 01, 2005 at 20:19 UTC ( [id://462645]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://462645]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 17:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found