Gossamer Forum
Home : General : Perl Programming :

Newbie logging question

Quote Reply
Newbie logging question
Hello everybody

I am completely new to Perl programming, so perhaps my question will sound stupid. But anyway, here it goes:

I run a have created a html-form which collects the answers with a cgi-script (written in perl), that stores the answers in a txt-file on the server. Everything works well, no problem here. My problem is that I would like to restrict access in that way, that people may only answer the survey (the form) once. On the Internet I have found many ways to do this by IP-logging, but the problem is that this will not work sufficiently, since most people in my area are using dial-up-Internet, hence they will get a fresh ip-number every time they log on to the net.

My plan was to use some kind of simple logging based on the information people have given, say their telephone number. In this way they can only leave one answer per telephone number (ok, so they may provide fake telephone numbers, but lets use this as an example). I can create a small log file (txt format) by:

open(OUTPUT, ">>$log");
print OUTPUT "\n";
print OUTPUT "$contents{'tel'}";
close (OUTPUT);

where ">>$log" is the defined log.txt file.

Now my question is, how do I get the cgi-script to check the log-file if a given telephone number exist, and if so restrict the users from answering the survey. If the phone number does not exist, the script would save it to the log and continue processing the answers in a normal manner.

I guess there is a very simple solution to this "problem", but I just can't find it on my own. I would appreciate any tips on how to get me on the right direction.

Best regards,

Jonas