[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Load file to array ?



On Fri, 17 Jul 1998, Len wrote:

>What's the best way to load a text data file into an associative array ?

Now that is a vague question. A general answer is:

 - Read one line from the file at a time;
 - Get rid of the end-of-line (chomp);
 - Split the line into parts;
 - Extract the desired key;
 - stick the data from the line into the hash for this key.

Personally, I like tab-delimited text files. Spreadsheets can easily
save in this format. Tabs are then not allowed in a field, but they
usually aren't, in a spreadsheet, anyway. This protext you from the
troubles of reading in data from a comma separated values file.

Good enough?
HTH,
Bart.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch