in reply to basic auth under Apache::Registry

There are two ways. The first argument passed to your script will be $r, so you can just do my $r = shift; at the start. Alternatively, you can get $r like this:
my $r = Apache->request();