Thanks Sergey,

That was just staring at me in the face.

If anyone is interested a little code to spit back the latitude and longitude 
of an address.  Next step is to get it too pull the address from a mysql 
database and then update it.  

++++++++++++++++++++++++++++++++
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;

print "Enter your address\n";

chomp (my $rawaddress = <>);

my $geoaddress = $rawaddress =~ s/ /\+/;
#strip the spaces from the address

my $googlekey = 
"ABQIAAAAJKeZa28YtErALcrbEC0UlBREf5oWR6F07BQvSEe3pww8R4s0VhTfTt-19vTI9qA-_V1pUf4-_TcfpQ";
#get your google http://code.google.com/apis/maps/signup.html

my $geocode_csv = 
get("http://maps.google.com/maps/geo?q=$geoaddress&output=csv&sensor=false&key=$googlekey";)
 
or die 'Unable to get page'; 
#return the google csv data

my @geoarray = split(/,/, $geocode_csv); 
#break the csv into fields

print "$geoarray[2],$geoarray[3]\n"; 
#print the longitude and latitude

exit 0;

++++++++++++++++++++++++++++++++
On Feb 19, 2010, at 4:00 PM, Sergey Matveev wrote:

> Greetings,
> 
> On Fri, Feb 19, 2010 at 03:54:27PM -0500, Erik Lewis wrote:
> 
>> I have to changes all the spaces in a string to +'s.  Is there an easy way 
>> to do this.  The length of the string and the number of spaces will always 
>> be changing.  
> 
> $string =~ s/ /\+/g;
> 
> That is all. All spaces will be replaced.
> 
> -- 
> Happy hacking, Sergey Matveev
> FSF Associate member #5968 | FSFE Fellow #1390
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to