|Welcome to the Monastery|
Reading file into an array and working with it.by Speedfreak (Sexton)
|on Jun 25, 2000 at 20:14 UTC||Need Help??|
Speedfreak has asked for the
wisdom of the Perl Monks concerning the following question:
One day I am going to get this nailed but until then, can someone please guide me in the ways...
Heres the problem:
I have a CSV file which contains a list of places plus there position on the planet in Latitude and Longtitude stored as decimal.
Now, the prinicpal is to select one of these locations and return a list of places within a defined square area of a certain size.
First problem is that I have to open this CSV file and search it for the place selected to get its Lat/Lon pair. I then have to re-search it for all the places who's position is close based on the search area.
My theory was to create a 2 dimensional array (sort of rows/cols if you will), by reading lines in, splitting them by the delimeter and putting the values in the second dimension. I would then index a line by the first.
However, reading my Perl docs and books I have, I cant seem to find how to do this.
However I do it I need to complete the following steps.
1) Open the CSV file and pull it into an array.
Can anyone advise me on this? I am completely lost and dont want to have to parse a file from disk twice and putting it into an array and searching it twice seems to me to take less disk overhead than using a simple SQL query.