in reply to Reading file into an array and working with it.

Anytime you find yourself iterating through an array, looking for a specific value, you should stop and ask "Would a hash be better here?"

What I would do:

  1. Open the file.
  2. For each line, split it into $name and $location.
  3. Put the data into two hashes -- one in the format $name => $location, the other $location => $name.
  4. Close the file.
  5. Look up the location by name from the first hash.
  6. Write a couple of loops to cover the coordinates of the preefined area around the place (add to and subtract from the Lat/Lon values).
  7. Look up names (if they exist) by location in the second hash.
You might also look at the DBM file modules included with Perl, like DB_File, GDBM_File, NDBM_File, and ODBM_File. Also be aware that parsing many CSV files with a regex (even in a split statement) is tricky, so Text::CSV may come in handy.
  • Comment on Re: Reading file into an array and working with it.