use strict; use warnings; use Apache2::Directive (); use Apache2::ServerUtil (); use Data::Dumper; my $conf = <<'EOC'; ServerName www.example.com DocumentRoot /www/www.example.com/htdocs/ EOC Apache2::ServerUtil->server->add_config([split /\n/, $conf]); my @vhosts = Apache2::Directive::conftree()->lookup('VirtualHost', '*:80'); print(Dumper(\@vhosts));