Michael Dearman <[EMAIL PROTECTED]> wrote:
> I've come close to figuring this one out buy following some of the
> questions I've seen here. But...
> 
> <H1>Hello $ENV{REMOTE_HOST}</H1>
> 
> The remote host doesn't show. Printing out the %ENV, it tain't there.
> But where does Perl get it. From CGI.pm (which is installed) or where?

%ENV is the environment.  CGI uses the environment to pass values from
the web server to the CGI program.  If your script was running under
CGI, the web server would put REMOTE_HOST, and other things, in the
environment, before forking to run your script.  But you're not using
CGI, you're using mod_perl.  The server isn't setting CGI environment
variables and forking to run your script.  Your script is being run by
a code module that is part of the web server.  You need to use Apache
specific calls to get the information you need from the web server.
mod_perl makes this easy to do using the "Apache request object":

 $request = Apache->request;
 $connection = $request->connection;
 $remote_ip = $connection->remote_ip;

Read more about the request object in the mod_perl documentation, to
find out how to ask it for the other kinds of information a CGI script
normally gets out of the environment.  Remember, mod_perl is not CGI
(although with Apache::Registry it can look quite similar to CGI)

  --  Cos (Ofer Inbar)  --  [EMAIL PROTECTED]  [EMAIL PROTECTED]
  --  Exodus Professional Services  --  [EMAIL PROTECTED]
 "This may seem a bit weird, but that's okay, because it is weird."
    -- Larry Wall in perlref(1) man page, Perl 5.001

Reply via email to