Click to See Complete Forum and Search --> : Perl + Date


MrNewbie
07-29-2001, 08:53 AM
I need to make a chat room cgi script in perl that is actually more like a message board, it allows people to post a message and it then appears on the chat page, everyday the chat page is archived and a new one is produced the file will be the date, something like 07292001.html, 07302001.html etc but I want all of these files to be deleted after one year, my problem is, how will I be able to test if the files are deleted after one year without actually waiting that long? Is there way to pass a perl program a date and make it think that it is that date? I need it to be working properly before I use it because I won't be in charge of it from after it is finished.
Thanks for any help

[ 29 July 2001: Message edited by: MrNewbie ]

TheLinuxDuck
07-29-2001, 02:37 PM
My first thoughts are:

If it is going to be a 'maintenance' type script that runs nightly, then you can make a sub that actually handles the deletion. Then, when it is called in the nightly script, it could be called as:

deleteYearOldFiles((localtime)[4]+1,(localtime)[3],(localtime)[5]+1899);

:which would give you one year, to date, back. The sub 'deleteYearOldFiles' will actually take care of all the deletion and the like.. and, it gives you the flexibility, during testing, to put any date you want into it, such as:

deleteYearOldFiles(12,1,2000);

:giving you the ability to easily delete any dated files, to verify it works.

Chances are there is a better way to handle this, but as I said, this is the first thing of which I thought. (^=

Hope this helps!

MrNewbie
07-29-2001, 02:53 PM
Thanks, using that I think I can manage to delete the files, I'm going to do it like this, when someone posts, everything that is over one year old is deleted, so if the script isnt run on a particular day then the next time it is then the file one year older than the day it wasnt run will also be deleted. I also have one more question that I'll post here instead of starting a new thread, when I use CGI.pm or the ENV{'QUERY_STRING'} method of getting values submitted to my scripts I always end up having huge urls that are being accessed like:
http://www.domain.com/cgi-bin/script.pl?user=username&pass=password&action=login&message=message

And on and on depending on whats been submitted, so I wanted to know if theres a way to hide all of that and not have it displayed in the address bar?
Thanks

Mikenell
07-29-2001, 08:18 PM
Using post as the method instead of get stops the string being in the address bar.

MrNewbie
07-30-2001, 09:47 AM
Thanks!