Writing Data to a File, Continued
Detour:
An easy way to do it with CGI.pm
Think this through a little bit:
Assume we're collecting bearcat ID, first name, and last name from an HTML form.
First, we get the data from the web page.
Next, we write the data to a file, but we need a special character, called a delimiter, to separate the fields.
Tab is common, but you can use anything.
Just make sure the user did not use that same character. If so, your file will be corrupt!
Write bearcatID, delimiter, firstname, delimiter, lastname, then the new line escape.
That way, each visitor will have a unique line in the file, containing all of his/her data.
A file written from a page with three visitors would like like this:
jonesbr~Brandan~Jones
goodmasm~Goodman~Spiff
wayl~Lee~Way
Now, we have three records in a file, with three fields of data each. Think of an Excel spreadsheet with data in three colums and three rows.
Example:
writedata.html
Now, read it back in
Home