On Tue, 13 Jun 2000, Richard L. Goerwitz wrote:

> To get a list of virtual servers -
> 
> > > > for (my $s = Apache->server; $s; $s = $s->next()) {
> > > >         print "Virtual host: ", $s->server_hostname, "\n";
> > > > }
> 
> > > Is there any reasonable way to use the list of servers (successive
> > > values of $s above) to determine what mod_perl PerlSetVar directives
> > > have been issued for each virtual host?
> > >
> > > E.g., is there some clever way to use Apache::ModuleConfig->get ()
> > > to do this?
> > 
> > $s->dir_config() should work.
> 
> You've actually hit upon my original reason for writing.  For whatever
> reason, the following code doesn't work for me.  The dir_config routine
> doesn't find what it's looking for (although it should - or at least so
> I thought):
> 
> sub handler () {
> 
>   my $r = shift;
>   my $vserver;
> 
>   $r->status (OK);
>   $r->content_type ('text/plain');
>   $r->send_http_header ();
> 
>   for ($vserver = Apache->server; $vserver; $vserver = $vserver->next) {
>     $r->print ('server: ', $vserver->server_hostname(), "\n");
>     $r->print ('port: ',   $vserver->port(), "\n");
>     $r->print ('variable value: ', $vserver->dir_config
> ('SomePerlVariable'), "\n");
>   }

OK then, try this:

for ($s = Apache->server; $s; $s = $s->next) {
        my ($server, $port) = ($s->server_hostname, $s->port);
        $r->print('server: ', $server, "\n");
        $r->print('port: ', $port, "\n");
        
        my $subreq = $r->lookup_uri("http://$server:$port/");
        $r->print('variable value: ',
$subreq->dir_config('SomePerlVariable'), "\n");
}

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org

Reply via email to