Wednesday, May 20, 2009

perl: get IP address of your website user

Share at Facebook

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


muthu said...

I find my website user using this From this Article U give the new way to find website user using perl script.Its new to me.

IGM Computers said...

This is great. I've spent hours trying to find how to track my website users' IP addresses. Thanks