Thank you Monks. The first reply actually handled my problem well. But an explanation is warranted, especially since it may well give me insight on bettering my code.
I am reading in data from a sybase server. Each record has an id_num, persons, and many other fields (20). Unfortunately, the way the data is captured in the database, persons are listed in a varchar(255) field by their first name and coma seperated:
3255|bob,mary,sally,tom|2003-10-22|0|1|2003-07-01| ...
I'm need to keep each record complete by its id_num and all other fields, but I need to do various tasks based on the persons contained in each record. One of the tasks is to produce a cgi drop down list box form that would list each person. Selecting that person would then show each project they are tasked with.
I am reading in the line and creating an array of that field by splitting on the coma's. But again, each record has multiple persons (up to five).
Thanks Again,
Louis | [reply] |
It sounds like you need a hash with the key being the person's name and the value being an array reference containing the idnum of each project associated with that person.
Of course, I would strongly recommend having the person who owns the database normalize their data. You would need a project table, a person table, and another table that associates the two. That would make your life a lot easier. (And, it would make your web app a lot faster, as you wouldn't have to re-normalize the data every time.)
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
| [reply] |