Hey, fun script! Hope you don't mind, but I figured I would tighten it up a bit, add strict, and make it cross-platform compatible by using LWP::Simple.
#!/usr/bin/perl -w use strict; use LWP::Simple; my @x =('192.172.226.77'); foreach my $ipaddress (@x) { my $url = "http://netgeo.caida.org/perl/netgeo.cgi/netgeo.cgi?". "method=getLatLong&target=$ipaddress&.cgifields=method&.cgifie +lds=nonblocking"; my $result= get( $url ); my ( $lat, $long ) = ( $result=~ /LAT:\s+(-?\d+\.\d+).*LONG:\s+(- +?\d+\.\d+)/s ); $lat += 180 if $lat < 0; $long += 180 if $long < 0; print "Address: $ipaddress\tLat: $lat\tLong: $long\n"; }
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In reply to (Ovid) Re: Getting longitude and latitude from an IP address
by Ovid
in thread Getting longitude and latitude from an IP address
by Kickstart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |