perl: get IP address of your website user

From your Perl/CGI script, you can easily get the remote IP address of the user who is browsing your website. I'm providing a tiny code that will simply print out the IP address of the user.

use CGI; ## load the cgi module

print "Content-type: text/plain; charset=iso-8859-1\n\n";
my $q = new CGI; ## create a CGI object
print $q->remote_host(); ## print the user ip address


The output will be the simply the IP address of the user who will browse the page. You'll find more about the CGI module of Perl at http://perldoc.perl.org/CGI.html

Comments

muthu said…
Hai,
I find my website user using this sitewww.ip-details.com.But From this Article U give the new way to find website user using perl script.Its new to me.
Pixel Cottage said…
This is great. I've spent hours trying to find how to track my website users' IP addresses. Thanks