Bowen,Rich,rbowen@rcbowen.com,CGI ProgrammerThe commas indicate the different fields. The problem occurs if one of the fields might contain a comma. For example, suppose my title (the last field) was "Ruler of Space, Time, and Dimension." There would be no way to know if those commas were part of the field, or if they indicated a break between fields.
And, so, when using text data files, it is important to choose your delimiters in such a way that they are never going to be part of any field, to cause this sort of confusion.
Since it is always possible that a particlar character might show up in a field, I recommend using multi-character delimiters, such as ### or %%% or ~~~, which are extremely unlikely to ever be a part of one of my data fields.
Writing and reading data to/from these files is then simply a matter of knowing what your delimiter is, and what order the fields are to be in.
$delimiter = "%%%"; $new_record = join $delimiter, $field1, $field2, $field3, $field4, $field5; print DATAFILE "$new_record\n";
open (DATA, "$datafile"); $record = <DATA>; ($field1, $field2, $field3, $field4, $field5) = split /$delimiter/, $record;