I'm trying to make a cgi script that can access and record the Computer Name of the computer that visits a particular website.

I'm writing the script on a Win2K laptop, and the people accessing the page will be doing so from Win2K as well. The webpage and scripts are hosted on some Unix flavour though. I am pretty sure the Perl version on the Unix is 5. I'm not able to easily add any other modules though.

This will work fine for both Windows and Unix, but only if there isn't a proxy or firewall or ISP in between. I don't know if there's another possibility to get the 'real' name of the computer. I there is another way, please let me know!

Or you could use the environment variable $ENV{REMOTE_HOST} instead of doing the name lookup. The variable may not be set on all systems, though. It depends on the web server which ENV vars get set. So you should make a quick script to print out all the ENV vars on the system to see which ones the web server is setting. My advice is if $ENV{REMOTE_HOST} is there, then use it.

I thought you've just adapted my version a little (if you'll look at my 1st post here, you'll see that we're talking about very similar solutions here - my solution is longer because I'm not a "golfer" and that wasn't my intention to write the shortest possible code ). Jean SpectorSQA Engineer @ Exanetjean.spector@softhome.net

There are only 10 types of people in the world - Those who understand binary, and those who don't.

My intention also wasn't to write it in the shortest possible way. If I had been golfing, I think I would have posted something else. (As there's so many redundant whitespace in my code... )

My intention was to show that foreach and for can be interchanged. This is hard if you come from C (as I do) but if you're a "native" Perl speaker this is easy and saves you lots of typing. Another thing that I really like about Perl is that you can leave away parentheses in so many places and the fact that this can really improve readability. Again, this is a little hard for C programmers...

-- mhx

P.S.: Even shorter:

Code

print Dumper \%ENV;

Assuming you have the invaluable Data::Dumper module already loaded. At last with an effort he spoke, and wondered to hear his own words, as if some other will was using his small voice. "I will take the Ring," he said, "though I do not know the way."