At what point do you want to know this information? Is it going to be when they are requesting a page that is being fed to them by a Perl script? Is it when you're going through the logs later on with a Perl script? How are they "coming" to your system? HTTP? FTP? Telnet?

Now, to make a few assumptions: You are refering to HTTP traffic as it is being requested through CGI. In this case, you could either attempt to track down the IP number the requestor is giving using IP::Country, Apache::Geo::IP, or just Geo::IP, accepting the fact that some IP numbers are multi-national and also that a user can be in one location, requesting a document through a proxy located somewhere totally else.

Another option is that you could check the values of Accept-Language and assume they are where their first choice is (although this is going to be set to US most of the time by default) or look within the User-Agent field for some value that might be set. Using this method (or one like it) you have to accept that the requestor can put bad data into the header, so it, too, cannot be guaranteed to be correct.

- - arden.


In reply to Re: How to check the origin ofi a visitor? by arden
in thread How to check the origin ofi a visitor? by cranberry13

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.