[ back to toc ]

Perl

Date: 2002/02/09 17:19

Q:
If i have the number 1 sitting in a text file, and someone fills out a
form, how can i make the number 1 go to the number 2 and so on.

Basicly everytime someone fills out a form it adds 1 to the text file, but
makes the number go up 1 instead of just adding the number 1.
A:
You have to be careful to lock the file so that no two programs open it
the same time.

opent he file with +< (read write.
flock the file
read the line
seek to start
truncate the file
print the new value
flock release the file
close the file.

Look up the actual Perl functions: open, close, print, seek, flock and
truncate.

Regards,
Peter

[ back to toc ]