think tank forum

technology » Perl Question

Chiken's avatar
14 years ago
link
Chiken
Don't Let Your Walls Down
so i'm writing a perl log analyzer for one of my classes and i want the perl script to find pages that haven't been modified in a year. heres how i plan to do it, im reading each line of the web log, then splitting it at every space into an array. im going to use a nested loop statement to first test the status code, if 200 then test the file being accessed. if it's an .html, .php, .HTML, or .xhtml then create a new array that uses the stat command on the full file path, then add 31556929 to the modified time field of the array and compare it to the current time. if the modified time is <= current time then add the page to an array.

i guess my biggest question is, will this work. will the perl script be able to get the file stats of files that are not in my directory but other students directories? i would test this but i dont have access to the testing environment for like two weeks.
Chiken's avatar
14 years ago
link
Chiken
Don't Let Your Walls Down
hmmm, nm, i guess -M will work better for this than stat.
nny's avatar
14 years ago
link
nny
M̮͈̣̙̰̝̃̿̎̍ͬa͉̭̥͓ț̘ͯ̈́t̬̻͖̰̞͎ͤ̇ ̈̚J̹͎̿̾ȏ̞̫͈y̭̺ͭc̦̹̟̦̭̫͊̿ͩeͥ̌̾̓ͨ
http://www.nycresistor.com/2010/03/04/march-madness-day-3/ a log analyzer i wrote in perl.
andre's avatar
14 years ago
link
andre
It depends on the server config, but most likely you won't be able to get that info if you run the script with your user. One alternative would be to run it as a cgi/mod_perl script; apache must have access to everyone's files, so if you run your script as the apache user, it should work.
Chiken's avatar
14 years ago
link
Chiken
Don't Let Your Walls Down
damn, thats crazy nny. maybe someday, what i've used perl more i could pull something like that off. im still in the, just started learning phase :p
nny's avatar
14 years ago
link
nny
M̮͈̣̙̰̝̃̿̎̍ͬa͉̭̥͓ț̘ͯ̈́t̬̻͖̰̞͎ͤ̇ ̈̚J̹͎̿̾ȏ̞̫͈y̭̺ͭc̦̹̟̦̭̫͊̿ͩeͥ̌̾̓ͨ
dumping your access logs into an innodb is a great way to kill your mysql box =P