my $r = Apache->request;
To set the script up as Apache::Registry, add something like this to
httpd.conf:
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
</Location>
This sets up the perl subroutine under the document root
to run under Apache::Registry. So put your script there.
Or, if you set up a
mod_perl handler, your handler subroutine will be passed
$r.
For example, you might set up a handler thusly in your httpd.conf:
<Location /foo>
SetHandler perl-script
PerlHandler My::Foo
</Location>
And then in My::Foo:
package My::Foo;
use strict;
sub handler {
my $r = shift;
my $user = $r->connection->user;
my($ret, $password) = $r->get_basic_auth_pw;
$r->send_http_header;
$r->print($user);
$r->print($password);
}
1;
I'd recommend trying the first approach. |