IPtoLL is a hostname to latitude/longitude conversion tool
(perl module) that uses whois and the DBI module to
interface with a relational database (like SQL) in which a
domain-to-city cache and city-to-location database are
stored. Not perfect but it does work suprisingly well.
http://www-unix.mcs.anl.gov/~olson/IPtoLL.html
Update: You can't automatically determine the
general geographic location of a visitor with greater than
national resolution. What you can do is determine
the address listed in the DNS record that may or may not
correspond to the general location of the box the visitor
is accessing your site with. Most of the time the user is
in the same country the request came from, if the DNS
record is correct.
--
Check out my Perlmonks Related Scripts like framechat,
reputer, and xNN.