in reply to Sort by distance

Use use strict; use warnings;!!!

@zip_dist is never assigned anything.

$km = (@zip_dist); surely doesn't do what you want it to do. An array in scalar context returned the number of elements in the array.

$count++; is rather useless outside of a loop.