intranetman has asked for the wisdom of the Perl Monks concerning the following question:
The other variabels I wish to obtain, but do not show up are as follows:$ip_addr = $ENV{'REMOTE_ADDR'}; $host_name = gethostbyaddr(inet_aton($ip_addr), AF_INET); $req_method = $ENV{'REQUEST_METHOD'};
I know I can get all of the variables by doing the following:$host_port = $ENV{'REMOTE_PORT'}; $user_agent = $ENV{'HTTP_USER_AGENT'}; $mac_address = `/sbin/arp -a $ip_addr` =~ /at\s+(\S+)\s+/; $user_referer = $ENV{'HTTP_REFERER'};
But that seems a little longwinded and unnecessary. If anyone could suggest something shorter or possibly point out what I'm doing wrong that would be great. Thank again!#!/usr/bin/perl print "Content-type: text/html\n\n"; $n = 0; print "<tt>\n"; foreach $key(sort keys(%ENV)) { print "$key = $ENV{$key}<p>"; @keys[$n] = $ENV{$key}; $n++; } print qq~The remort port is $keys[15]~;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTTP/CGI Environmnet Variables
by Tanktalus (Canon) on Mar 01, 2005 at 21:23 UTC | |
by intranetman (Acolyte) on Mar 01, 2005 at 22:23 UTC | |
|
Re: HTTP/CGI Environmnet Variables
by ikegami (Patriarch) on Mar 01, 2005 at 22:17 UTC | |
|
Re: HTTP/CGI Environmnet Variables
by chas (Priest) on Mar 01, 2005 at 21:43 UTC | |
by intranetman (Acolyte) on Mar 01, 2005 at 22:18 UTC | |
|
Re: HTTP/CGI Environmnet Variables
by sh1tn (Priest) on Mar 01, 2005 at 22:21 UTC | |
by intranetman (Acolyte) on Mar 01, 2005 at 22:48 UTC |