Writing to an External File
-
Start with the open line.
-
Then, just use the print statement, followed by the filehandle, followed
by the data you wish to print.
-
Finally, close the file so that others can use it.
open(DATA, ">>../userdata.txt") || &error;
print DATA "This is my input data.\n";
print DATA $inputData;
close(DATA);
-
You may want to lock this file so that it can be used by only one person
at a time. To do so,
flock(DATA,2); to lock, and
flock(DATA,8); to release.
-
Example: Class
Registration Page
Reading Data
Home