CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Getting a file's attributes with CGI?



Nov 22, 2000, 11:51 AM

Post #1 of 2 (263 views)
Getting a file's attributes with CGI? Can't Post

Just wondering if anyone knows of a way to get the file attributes of items in a directory.

Globbing teh directory will get you a list of file names, but I can't seem to find any documentation on getting the attributes of each file.

Specifically, I would like to know the Last-Modified date of a particilar file. My eventual goal is user profiles that are autimatically removed if the user does not log in after X weeks.
I could put that as a value in the profile, but then I'd have to open the user datafile and read in the info from each person.
I'm thinking with file attributes it would be easier to just check the modified date and delete and idle files.
(since logging into the site already instantly modifies the user's data file.)

any hints or suggestions? :)
Thanks in advance!

Living life -umop apisdn-


Nov 22, 2000, 12:19 PM

Post #2 of 2 (263 views)
Re: Getting a file's attributes with CGI? [In reply to] Can't Post

perldoc -f stat

print "Last modified: ", scalar(localtime (stat $filename)[9]);


-M Modification age in days
-A Access age in days

$_ = "file.txt";
print "$_ was last modified ".int(-M)." days ago\n" if -f;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives