Wednesday, May 20, 2009

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

2 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.

IGM Computers said...

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

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...