NY,00501,00501
NY,00544,00544
...and so on
It's state abbreviation, zip code range for that state (start, end)
I have another file <FILE2> for each state that contains all the zip codes and cities for that state in this format:
10918|Chester
10919|Circleville
...and so on
What I want to do is read in another file <FILE3> that contains a zip code I want to match with a city. So, the logic is...
Read in zip code from <FILE3>
check against data in <FILE1>
if zip code falls in the range then open the proper state file <FILE2>
match the zip from <FILE3> to the city in <FILE2>
return the zip, city, state
I got this to work with using nested foreach loops but seems slow, especially with a huge list of zips to check. I'm thinking that is not a very optimal way to do this. It was suggested I use a hash of hashes but this newbie got confused ;-)
Any ideas?? Thanks Tim
In reply to How to match zip code to city,state by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |