The easiest approach is to traverse your list of locations and compute the distaance of each location from your designated position. To get locations of zip codes, try
Geo::Coder::US:
use Geo::Coder::US;
Geo::Coder::US->set_db( "geocoder.db" );
my ($ora) = Geo::Coder::US->geocode(
"1005 Gravenstein Hwy N, 95472" );
print "O'Reilly is located at $ora->{lat} degrees north, "
"$ora->{long} degrees east.\n";
To compute distances, use
Geo::Ellipsoid:
use Geo::Ellipsoid;
$geo = Geo::Ellipsoid->new(ellipsoid=>'NAD27', units=>'degrees');
@origin = ( 37.619002, -122.374843 ); # SFO
@dest = ( 33.942536, -118.408074 ); # LAX
( $range, $bearing ) = $geo->to( @origin, @dest );
($lat,$lon) = $geo->at( @origin, 45.0, 2000 );
( $x, $y ) = $geo->displacement( @origin, $lat, $lon );
@pos = $geo->location( $lat, $lon, $x, $y );
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.