|
Hi, dont worry with this query too much because its just for curiousity and i found it difficult to explain my problem.
Project deadline is over. It was based around using perl with flat-file databases, my job was to do searches particularily between 2 files. I only managed to get part of my searches working but too late to worry now. I had troubles with sorting the database, perhaps because of the methods i was using. I strictly read from files, store their info in arrays and did the searches based on that. Im thinking now that it wasnt the best way to go about it, since an array will only store one column of information.
My search was done by finding a match between a column in one file, whilst using a counter ($i++ each time i went through the loop), and using that variable value to print out the related data to the match by going through separate arrays, each array containing a column of information.
For example, where i found a match of rooms, i would grab that $i value, and extract the data like so:
# predefined arrays
@roomipark;
@roomicapacity;
@roominame;
@roomilab;
extracting the data with filled in arrays:
print"$roomipark[$i]";
print"$roomicapacity[$i]";
print"$roominame[$i]";
print"$roomilab[$i]";
So, how would i sort the data if i had a list of $i values?
I am thinking its the way that im storing the data thats at fault.
Perhaps associative arrays is the answer to my riddle, but to my understanding, those arrays only relate to two pieces of information. I would rather have an explantion to the technique i must use but if code helps u explain it then feel free. This is purely for curiosity as i am now going to convert the whole thing into a relational database using PHP and MYSQL. Thanks for reading and any help given,
pungi
|